Skip to content

[ADD] sentry module - #761

Merged
lasley merged 2 commits into
OCA:10.0from
versada:contribute_sentry_module
Jun 29, 2017
Merged

[ADD] sentry module#761
lasley merged 2 commits into
OCA:10.0from
versada:contribute_sentry_module

Conversation

@naglis

@naglis naglis commented Mar 6, 2017

Copy link
Copy Markdown
Contributor

Hello all,

as discussed in HBEE/odoo_sentry#5, we would like to contribute the Sentry error reporting integration module to OCA.

I have made the following changes in comparison to our fork:

  • Added the ability to specify in Odoo config file the class names of errors, which should not be reported to Sentry. The old option (sentry_report_user_errors was removed).
  • Added the ability to specify in Odoo config file the logger names, which can be ignored from reporting to Sentry (option sentry_exclude_loggers).
  • Added the SanitizeOdooCookiesProcessor to sanitize sensitive cookies (session_id) in Odoo side (see also [FIX] fix security issue, as the module leak the cookies into sentry versada/odoo_sentry#6). Also added the ability to configure which processors to use in Odoo config file.
  • sentry_client_dsn config key renamed to simply sentry_dsn.
  • Added the ability to configure more raven client options via Odoo config file.
  • Odoo WSGI application is now wrapped by the Sentry middleware in order to report errors in HTTP controllers more nicely. (AFAICT, this also requires the sentry module to be added to server_wide_modules list, otherwise, the wrapping does not work.)
  • Refactored to comply with OCA guidelines.
  • Added a few basic tests.

@barsi, I have included your name as one of the authors in __manifest__.py and README.rst but I was not sure if I should include it in the copyright notices in each Python file. Please let me know if you would like me to add it.

Regarding Odoo versions 8.0 and 9.0 -- I will be happy to provide backports to both of these versions if/once this is merged.

@bealdav

bealdav commented Mar 10, 2017

Copy link
Copy Markdown
Member

Travis error are:

2017-03-06 08:32:46,628 5693 ERROR openerp_test odoo.modules.module: Module auth_signup_verify_email: 0 failures, 2 errors

2017-03-06 08:32:38,806 5693 INFO openerp_test odoo.addons.mass_editing.tests.test_mass_editing: ` Test if related actions are removed when mass editing record is unlinked.

2017-03-06 08:32:38,893 5693 WARNING openerp_test odoo.models: ir.actions.act_window.create() includes unknown fields: auto_refresh

====

I use with success v8 version of this module in production

@lasley lasley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ it! Few minor comments, but otherwise LGTM

Comment thread .travis.yml Outdated
- travis_install_nightly
# Install libraries that require specific development headers, but not during lint test
- if ! [ "$LINT_CHECK" = "1" ]; then pip install pymssql MySQL-python pyodbc; fi
- if ! [ "$LINT_CHECK" = "1" ]; then pip install pymssql MySQL-python pyodbc raven; fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move these to requirements.txt

Comment thread sentry/README.rst Outdated
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/maintainer-tools/issues>`_. In case of trouble, please

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/maintainer-tools/server-tools

Comment thread sentry/__manifest__.py Outdated
{
'name': 'Sentry',
'summary': 'Report Odoo errors to Sentry',
'version': '10.0.0.1.0',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10.0.1.0.0

Comment thread sentry/const.py
'odoo.exceptions.UserError',
'odoo.exceptions.ValidationError',
'odoo.exceptions.Warning',
'odoo.exceptions.except_orm',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and odoo.exceptions.QWebException

Take a look at the below though - maybe we could leverage something like this to make the module a bit more future-ready?

>>> from odoo import exceptions
>>> dir(exceptions)
['AccessDenied', 'AccessError', 'DeferredException', 'MissingError', 'QWebException', 'RedirectWarning', 'UserError', 'ValidationError', 'Warning', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_logger', 'currentframe', 'except_orm', 'frame_codeinfo', 'logging']
>>> [e for e in dir(exceptions) if not e.startswith('_')]
['AccessDenied', 'AccessError', 'DeferredException', 'MissingError', 'QWebException', 'RedirectWarning', 'UserError', 'ValidationError', 'Warning', 'currentframe', 'except_orm', 'frame_codeinfo', 'logging']

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and odoo.exceptions.QWebException

Hm, QWebException does not look like a user error so maybe it would make sense to receive such errors?. Also, it's weird that QWebException is also defined in addons/base/ir/ir_qweb/qweb.py so I guess we should ignore both (if we decide to ignore).

Take a look at the below though - maybe we could leverage something like this to make the module a bit more future-ready?

Do you mean that we should analize the names in odoo.exceptions and look for Exception subclasses? IDK, the list of ignored exceptions is configurable, so one could add any new exceptions to the list in the config file. Also, analizing the exceptions at load time would feel a bit magic, i.e. you wouldn't really know which exceptions are ignored. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I didn't realize there were ignored exceptions here. Is there a reason we don't want to catch all exceptions raised by Odoo?

@lasley lasley Mar 29, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking for a bit (and drinking a bit of coffee), I think actually the better question is this:

What is the definition of a "User Error" in the context of this app , and how can they be changed ?

Edit: they can be changed with sentry_ignored_exceptions in Odoo conf. My bad on that miss.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odoo uses these exceptions as part of flow control and these exceptions are integrated more nicely with the client, eg. in Odoo 8, if you try to add a line to a SO before setting the partner in the SO form, you will get an except_orm informing about the partner not being set. I think getting such exceptions in Sentry would cause more noise than it would do good, so these are ignored by default (but, as you've noticed, it's configurable with sentry_ignored_exceptions).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @naglis - works for me!

@lasley

lasley commented Mar 28, 2017

Copy link
Copy Markdown
Contributor

@tedsalmon please review

@paulius-sladkevicius

Copy link
Copy Markdown

@lasley @tedsalmon any possibilities to merge it soon? We've other nice module based on this that would like to push too.

@paulius-sladkevicius

Copy link
Copy Markdown

@bealdav could help and give review, would like to close this PR.

@bealdav

bealdav commented Jun 28, 2017

Copy link
Copy Markdown
Member

👍

@lasley

lasley commented Jun 28, 2017

Copy link
Copy Markdown
Contributor

@bealdav - please use the Github review feature located in the "Files Changed" tab to indicate an official review. I assume the 👍 meant no suggestions, and an approval for merge?

@lasley
lasley merged commit 2df9859 into OCA:10.0 Jun 29, 2017
@lasley

lasley commented Jun 29, 2017

Copy link
Copy Markdown
Contributor

It makes me so happy to see this merged in OCA. Thank you for the contribution @naglis

@bealdav

bealdav commented Jun 29, 2017

Copy link
Copy Markdown
Member

Thanks a lot @naglis

@pedrobaeza

Copy link
Copy Markdown
Member

This merging is provoking an error starting Odoo server if you don't have raven library because of this line: https://github.com/OCA/server-tools/blob/10.0/sentry/const.py#L37

naglis pushed a commit to versada/server-tools that referenced this pull request Jun 30, 2017
@rgarnau

rgarnau commented Jun 30, 2017

Copy link
Copy Markdown
Contributor

Hi @naglis - I am still getting this error.

Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 180, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 168, in execute
application_iter = app(environ, start_response)
File "/home/.../Odoo-buildouts/odoo/parts/odoo/odoo/service/server.py", line 250, in app
return self.app(e, s)
File "/home/.../Odoo-buildouts/odoo/parts/odoo/odoo/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/home/.../Odoo-buildouts/odoo/parts/odoo/odoo/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/home/roser/Odoo-buildouts/odoo/parts/odoo/odoo/http.py", line 1307, in call
self.load_addons()
File "/home/.../Odoo-buildouts/odoo/parts/odoo/odoo/http.py", line 1328, in load_addons
m = import('odoo.addons.' + module)
File "/home/.../Odoo-buildouts/odoo/parts/odoo/odoo/modules/module.py", line 81, in load_module
execfile(modfile, new_mod.dict)
File "/home/.../Odoo-buildouts/odoo/parts/server-tools/sentry/init.py", line 10, in
from . import const
File "/home/.../Odoo-buildouts/odoo/parts/server-tools/sentry/const.py", line 37, in
'requests_synchronous': raven.transport.RequestsHTTPTransport,
NameError: name 'raven' is not defined

@naglis

naglis commented Jun 30, 2017

Copy link
Copy Markdown
Contributor Author

Hi @rgarnau,

the fix is still not merged, see #883.

@rgarnau

rgarnau commented Jun 30, 2017

Copy link
Copy Markdown
Contributor

Thanks @naglis

@naglis
naglis deleted the contribute_sentry_module branch June 30, 2017 13:19
njeudy pushed a commit to njeudy/server-tools that referenced this pull request Oct 23, 2017
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
njeudy pushed a commit to njeudy/server-tools that referenced this pull request Oct 23, 2017
tansadio pushed a commit to tansadio/server-tools that referenced this pull request Nov 28, 2017
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
tansadio pushed a commit to tansadio/server-tools that referenced this pull request Nov 28, 2017
njeudy pushed a commit to njeudy/server-tools that referenced this pull request Dec 3, 2017
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
njeudy pushed a commit to njeudy/server-tools that referenced this pull request Dec 3, 2017
dnplkndll pushed a commit to kencove/server-tools that referenced this pull request Dec 29, 2020
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
dnplkndll pushed a commit to kencove/server-tools that referenced this pull request Dec 29, 2020
moylop260 pushed a commit to Vauxoo/server-tools that referenced this pull request Jan 22, 2021
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
moylop260 pushed a commit to Vauxoo/server-tools that referenced this pull request Jan 22, 2021
luisg123v pushed a commit to vauxoo-dev/server-tools that referenced this pull request Jan 25, 2021
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
luisg123v pushed a commit to vauxoo-dev/server-tools that referenced this pull request Jan 25, 2021
atchuthan pushed a commit to kencove/server-tools that referenced this pull request May 27, 2021
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
atchuthan pushed a commit to kencove/server-tools that referenced this pull request May 27, 2021
airlessproject pushed a commit to airlessproject/server-tools that referenced this pull request Jul 18, 2022
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
airlessproject pushed a commit to airlessproject/server-tools that referenced this pull request Jul 18, 2022
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request Oct 17, 2022
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request Oct 17, 2022
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request Oct 20, 2022
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request Oct 20, 2022
SodexisTeam pushed a commit to sodexis/server-tools that referenced this pull request Jan 3, 2023
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
SodexisTeam pushed a commit to sodexis/server-tools that referenced this pull request Jan 3, 2023
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request Jan 26, 2024
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request Jan 26, 2024
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request Feb 5, 2024
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request Feb 5, 2024
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request May 13, 2024
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
aisopuro pushed a commit to avoinsystems/server-tools that referenced this pull request May 13, 2024
PieterPaulussen pushed a commit to The-O-Team/server-tools that referenced this pull request Jul 18, 2024
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
PieterPaulussen pushed a commit to The-O-Team/server-tools that referenced this pull request Jul 18, 2024
SiesslPhillip pushed a commit to grueneerde/OCA-server-tools that referenced this pull request Nov 20, 2024
Syncing from upstream OCA/server-tools (12.0)
SodexisTeam pushed a commit to sodexis/server-tools that referenced this pull request Dec 31, 2024
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
SodexisTeam pushed a commit to sodexis/server-tools that referenced this pull request Dec 31, 2024
atchuthan pushed a commit to sodexis/server-tools that referenced this pull request Dec 31, 2024
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
atchuthan pushed a commit to sodexis/server-tools that referenced this pull request Dec 31, 2024
omalbastin pushed a commit to omalbastin/server-tools that referenced this pull request May 7, 2025
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants