Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
26360ab
[ADD] sentry module (#761)
naglis Jun 29, 2017
72a0e53
[FIX] sentry: fixes missing `raven` library preventing loading of mod…
Jun 30, 2017
ac8d608
[MIG] sentry to V11
naglis Jun 29, 2017
e5ea064
[FIX] Better manage KEYS - FIELDS conversion
Jan 5, 2018
f4d307c
Enable setting a release option directly
aisopuro Jan 12, 2018
f5e51b3
Global pylint cleanup
simahawk Sep 3, 2018
057797c
migrate to 12.0
jeffery9 Nov 3, 2018
01f53ef
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Aug 31, 2019
8d52ede
[IMP] sentry: black, isort
IvanShirokikh Feb 27, 2020
eeea691
[MIG] sentry: Migration to 13.0
IvanShirokikh Feb 27, 2020
67d1e77
[REF] sentry: README.rst using gen_addon_readme.py locally
moylop260 Jun 8, 2020
faa0e80
[REF] sentry: Fix sentry title level
moylop260 Jun 8, 2020
9ea5cd8
sentry 13.0.1.1.0
OCA-git-bot Jun 8, 2020
fa5bd83
[MIG] sentry: Migration to 14.0
traviswaelbro Nov 17, 2020
6ae4546
Update translation files
oca-transbot Jan 31, 2021
c49d53c
[UPD] README.rst
OCA-git-bot Jan 31, 2021
e1a1afe
[UPD] Update sentry.pot
oca-travis Jan 31, 2021
0279fb2
[FIX] sentry: Warning when using classes from collections.abc
luisg123v May 13, 2021
9cc1eec
[FIX] sentry: enable use of "sentry_odoo_dir" config parameter
traviswaelbro Sep 25, 2021
0732adc
[IMP] sentry: migrate sentry-raven to new api sentry-sdk
fernandahf Jan 3, 2022
02db9f7
[FIX] sentry: Coerce numerical config values
paradoxxxzero Jan 4, 2022
31c471e
[FIX] sentry: Patch odoo.service.server wsgi app
paradoxxxzero Jan 4, 2022
199d50e
[FIX] sentry: warn about sentry_transport only if it is specified in …
paradoxxxzero Jan 4, 2022
6da1875
[FIX] sentry: Fix bad ported version
paradoxxxzero May 30, 2022
69de3a2
[MIG] sentry: Migration to 15.0
aisopuro Oct 17, 2022
e171ab9
[FIX] sentry: test failure due to incomplete transport init
aisopuro Oct 17, 2022
2e63a18
[UPD] Update sentry.pot
Oct 29, 2022
da77aeb
[MIG] sentry: Migration to 16.0
prabakaran04 Jan 3, 2023
cd7a69c
[UPD] Update sentry.pot
Jan 19, 2023
0403c4f
[FIX] sentry: change with_locals to include_local_variables variable
deivislaya Mar 17, 2023
218efc8
[FIX] sentry: downgrade sentry-sdk to compatible version
deivislaya Jun 3, 2023
2fd8db2
[FIX] Prevent capturing ignored exceptions
Jan 31, 2023
e381d49
Added translation using Weblate (Italian)
mymage Jan 2, 2024
11ebe06
[FIX] sentry: respect sentry_logging_level
aisopuro Aug 25, 2023
519ba9f
[IMP] sentry: increase test coverage
aisopuro Aug 28, 2023
3cd1468
[IMP] sentry: pre-commit auto fixes
aisopuro Jan 26, 2024
f710d83
[IMP] sentry: pre-commit manual fixes
aisopuro Jan 26, 2024
ca47256
[MIG] sentry: Migration to 17.0
aisopuro Jan 26, 2024
54b282f
[IMP] Add tests to increase coverage
aisopuro Jan 26, 2024
b84cd1a
[IMP] sentry: pre-commit auto fixes
atchuthan Dec 31, 2024
09cb7ce
[MIG] sentry: Migration to 18.0
atchuthan Dec 31, 2024
b75a01b
[IMP] bump sentry_sdk version
dnplkndll Jan 22, 2025
9856549
[UPD] Update sentry.pot
Jan 31, 2025
670da87
[BOT] post-merge updates
OCA-git-bot Jan 31, 2025
4775afa
[FIX] sentry: add compatibility with sentry-sdk from debian bullseye …
em230418 Jan 28, 2025
aab5d23
[BOT] post-merge updates
OCA-git-bot Feb 1, 2025
41bbe30
[FIX] sentry: temporarily exclude sentry_sdk>=2.23.1
nilshamerlinck Mar 19, 2025
8d4c0f1
[BOT] post-merge updates
OCA-git-bot Mar 24, 2025
92ea263
[FIX] sentry: event dropped if include_context key not present
StefanRijnhart Aug 12, 2025
bacbb48
[BOT] post-merge updates
OCA-git-bot Aug 20, 2025
2a3f1e2
[IMP] : pre-commit auto fixes
ntsirintanis Feb 9, 2026
b701d41
[19.0][MIG] sentry: Migration to 19.0
JohanEndare Nov 21, 2025
71015b8
[FIX] sentry: handle early post_load when http server is not ready
ntsirintanis Apr 15, 2026
ce4a395
[IMP] sentry: configParser - use sentry section
Kiplangatdan Apr 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dataclasses
numpy
odoorpc
openupgradelib
sentry_sdk>=2.0.0,<=2.22.0
202 changes: 202 additions & 0 deletions sentry/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

======
Sentry
======

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e2f1d0bc83bf031b61df768de9c2f6d4f1feb303facf171a8d1889fc6a2635ca
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/19.0/sentry
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-sentry
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows painless `Sentry <https://sentry.io/>`__ integration
with Odoo.

**Table of contents**

.. contents::
:local:

Installation
============

The module can be installed just like any other Odoo module, by adding
the module's directory to Odoo *addons_path*. In order for the module to
correctly wrap the Odoo WSGI application, it also needs to be loaded as
a server-wide module. This can be done with the ``server_wide_modules``
parameter in your Odoo config file or with the ``--load`` command-line
parameter.

This module additionally requires the sentry-sdk Python package to be
available on the system. It can be installed using pip:

::

pip install sentry-sdk

Configuration
=============

The following additional configuration options can be added to your Odoo
configuration file:

[TABLE]

Other `client
arguments <https://docs.sentry.io/platforms/python/configuration/>`__
can be configured by prepending the argument name with *sentry\_* in
your Odoo config file. Currently supported additional client arguments
are:
``with_locals, max_breadcrumbs, release, environment, server_name, shutdown_timeout, in_app_include, in_app_exclude, default_integrations, dist, sample_rate, send_default_pii, http_proxy, https_proxy, request_bodies, debug, attach_stacktrace, ca_certs, propagate_traces, traces_sample_rate, auto_enabling_integrations``.

Example Odoo configuration
--------------------------

Below is an example of Odoo configuration file with *Odoo Sentry*
options:

::

[options]
(...)
server_wide_modules = web,sentry

[sentry]
sentry_dsn = https://<public_key>:<secret_key>@sentry.example.com/<project id>
sentry_enabled = true
sentry_logging_level = warn
sentry_exclude_loggers = werkzeug
sentry_ignore_exceptions = odoo.exceptions.AccessDenied,
odoo.exceptions.AccessError,odoo.exceptions.MissingError,
odoo.exceptions.RedirectWarning,odoo.exceptions.UserError,
odoo.exceptions.ValidationError,odoo.exceptions.Warning,
odoo.exceptions.except_orm
sentry_include_context = true
sentry_environment = production
sentry_release = 1.3.2
sentry_odoo_dir = /home/odoo/odoo/

Usage
=====

Once configured and installed, the module will report any logging event
at and above the configured Sentry logging level, no additional actions
are necessary.

|Try me on Runbot|

.. |Try me on Runbot| image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:target: https://runbot.odoo-community.org/runbot/149/14.0

Known issues / Roadmap
======================

- **No database separation** -- This module functions by intercepting
all Odoo logging records in a running Odoo process. This means that
once installed in one database, it will intercept and report errors
for all Odoo databases, which are used on that Odoo server.
- **Frontend integration** -- In the future, it would be nice to add
Odoo client-side error reporting to this module as well, by
integrating `raven-js <https://github.com/getsentry/raven-js>`__.
Additionally, `Sentry user feedback
form <https://docs.sentry.io/learn/user-feedback/>`__ could be
integrated into the Odoo client error dialog window to allow users
shortly describe what they were doing when things went wrong.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20sentry%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Mohammed Barsi
* Versada
* Nicolas JEUDY
* Vauxoo

Contributors
------------

- Mohammed Barsi <barsintod@gmail.com>
- Andrius Preimantas <andrius@versada.eu>
- Naglis Jonaitis <naglis@versada.eu>
- Atte Isopuro <atte.isopuro@avoin.systems>
- Florian Mounier <florian.mounier@akretion.com>
- Jon Ashton <jon@monkeyinferno.com>
- Mark Schuit <mark@gig.solutions>
- Atchuthan <atchuthan@sodexis.com>

Other credits
-------------

- Vauxoo

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-barsi| image:: https://github.com/barsi.png?size=40px
:target: https://github.com/barsi
:alt: barsi
.. |maintainer-naglis| image:: https://github.com/naglis.png?size=40px
:target: https://github.com/naglis
:alt: naglis
.. |maintainer-versada| image:: https://github.com/versada.png?size=40px
:target: https://github.com/versada
:alt: versada
.. |maintainer-moylop260| image:: https://github.com/moylop260.png?size=40px
:target: https://github.com/moylop260
:alt: moylop260
.. |maintainer-fernandahf| image:: https://github.com/fernandahf.png?size=40px
:target: https://github.com/fernandahf
:alt: fernandahf

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-barsi| |maintainer-naglis| |maintainer-versada| |maintainer-moylop260| |maintainer-fernandahf|

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/19.0/sentry>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sentry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .hooks import post_load
27 changes: 27 additions & 0 deletions sentry/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2016-2017 Versada <https://versada.eu/>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Sentry",
"summary": "Report Odoo errors to Sentry",
"version": "19.0.1.0.0",
"category": "Extra Tools",
"website": "https://github.com/OCA/server-tools",
"author": "Mohammed Barsi,"
"Versada,"
"Nicolas JEUDY,"
"Odoo Community Association (OCA),"
"Vauxoo",
"maintainers": ["barsi", "naglis", "versada", "moylop260", "fernandahf"],
"license": "AGPL-3",
"application": False,
"installable": True,
"external_dependencies": {
"python": [
"sentry_sdk>=2.0.0,<=2.22.0",
]
},
"depends": [
"base",
],
"post_load": "post_load",
}
134 changes: 134 additions & 0 deletions sentry/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Copyright 2016-2017 Versada <https://versada.eu/>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import collections
import logging

from sentry_sdk import HttpTransport
from sentry_sdk.consts import DEFAULT_OPTIONS
from sentry_sdk.integrations.logging import LoggingIntegration

import odoo.loglevels


def split_multiple(string, delimiter=",", strip_chars=None):
"""Splits :param:`string` and strips :param:`strip_chars` from values."""
if not string:
return []
return [v.strip(strip_chars) for v in string.split(delimiter)]


def to_int_if_defined(value):
if value == "" or value is None:
return
return int(value)


def to_float_if_defined(value):
if value == "" or value is None:
return
return float(value)


SentryOption = collections.namedtuple("SentryOption", ["key", "default", "converter"])

# Mapping of Odoo logging level -> Python stdlib logging library log level.
LOG_LEVEL_MAP = {
getattr(odoo.loglevels, f"LOG_{x}"): getattr(logging, x)
for x in ("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET")
}
DEFAULT_LOG_LEVEL = "warn"

ODOO_USER_EXCEPTIONS = [
"odoo.exceptions.AccessDenied",
"odoo.exceptions.AccessError",
"odoo.exceptions.DeferredException",
"odoo.exceptions.MissingError",
"odoo.exceptions.RedirectWarning",
"odoo.exceptions.UserError",
"odoo.exceptions.ValidationError",
"odoo.exceptions.Warning",
"odoo.exceptions.except_orm",
]
DEFAULT_IGNORED_EXCEPTIONS = ",".join(ODOO_USER_EXCEPTIONS)

EXCLUDE_LOGGERS = ("werkzeug",)
DEFAULT_EXCLUDE_LOGGERS = ",".join(EXCLUDE_LOGGERS)

DEFAULT_ENVIRONMENT = "develop"

DEFAULT_TRANSPORT = "threaded"


def select_transport(name=DEFAULT_TRANSPORT):
return {
"threaded": HttpTransport,
}.get(name, HttpTransport)


def get_sentry_logging(level=DEFAULT_LOG_LEVEL):
if level not in LOG_LEVEL_MAP:
level = DEFAULT_LOG_LEVEL

return LoggingIntegration(
# Gather warnings into breadcrumbs regardless of actual logging level
level=logging.WARNING,
event_level=LOG_LEVEL_MAP[level],
)


def get_sentry_options():
res = [
SentryOption("dsn", "", str.strip),
SentryOption("transport", DEFAULT_OPTIONS["transport"], select_transport),
SentryOption("logging_level", DEFAULT_LOG_LEVEL, get_sentry_logging),
SentryOption(
"include_local_variables", DEFAULT_OPTIONS["include_local_variables"], None
),
SentryOption(
"max_breadcrumbs", DEFAULT_OPTIONS["max_breadcrumbs"], to_int_if_defined
),
SentryOption("release", DEFAULT_OPTIONS["release"], None),
SentryOption("environment", DEFAULT_OPTIONS["environment"], None),
SentryOption("server_name", DEFAULT_OPTIONS["server_name"], None),
SentryOption("shutdown_timeout", DEFAULT_OPTIONS["shutdown_timeout"], None),
SentryOption("integrations", DEFAULT_OPTIONS["integrations"], None),
SentryOption(
"in_app_include", DEFAULT_OPTIONS["in_app_include"], split_multiple
),
SentryOption(
"in_app_exclude", DEFAULT_OPTIONS["in_app_exclude"], split_multiple
),
SentryOption(
"default_integrations", DEFAULT_OPTIONS["default_integrations"], None
),
SentryOption("dist", DEFAULT_OPTIONS["dist"], None),
SentryOption(
"sample_rate", DEFAULT_OPTIONS["sample_rate"], to_float_if_defined
),
SentryOption("send_default_pii", DEFAULT_OPTIONS["send_default_pii"], None),
SentryOption("http_proxy", DEFAULT_OPTIONS["http_proxy"], None),
SentryOption("https_proxy", DEFAULT_OPTIONS["https_proxy"], None),
SentryOption("ignore_exceptions", DEFAULT_IGNORED_EXCEPTIONS, split_multiple),
SentryOption(
"max_request_body_size", DEFAULT_OPTIONS["max_request_body_size"], None
),
SentryOption("attach_stacktrace", DEFAULT_OPTIONS["attach_stacktrace"], None),
SentryOption("ca_certs", DEFAULT_OPTIONS["ca_certs"], None),
SentryOption("propagate_traces", DEFAULT_OPTIONS["propagate_traces"], None),
SentryOption(
"traces_sample_rate",
DEFAULT_OPTIONS["traces_sample_rate"],
to_float_if_defined,
),
]

if "auto_enabling_integrations" in DEFAULT_OPTIONS:
res.append(
SentryOption(
"auto_enabling_integrations",
DEFAULT_OPTIONS["auto_enabling_integrations"],
None,
)
)

return res
Loading
Loading