Commit Graph

13 Commits (e0fc2647739c62d46d90fe89929125c201b51da1)

Author SHA1 Message Date
Atte Isopuro 22c7105ffe [IMP] sentry: pre-commit manual fixes 2024-05-13 12:26:04 +03:00
Atte Isopuro 22657fd65d [IMP] sentry: increase test coverage 2024-05-13 12:22:13 +03:00
Atte Isopuro 20270d0248 [FIX] sentry: respect sentry_logging_level
Before this fix, the Sentry module sent events for WARNING-
level logs, even if sentry_logging_level was registered as
"error" or higher.

The fix itself is minor: setup of the integration mistakenly
set the hardcoded WARNING level to the event handler and the
sentry_logging_level to the breadcrumb handler, when they
should have been the other way around.

The largest part of the diff is a reworking of the tests in
order to properly replicate the issue:

* The test previously emitted a fake log event directly using
  the integration's handler's emit-method, which skipped the
  part of the logic that actually filters based on logging level.
  This has been changed to use a bespoke NoopHandler and dedicated
  Logger, so that the tests can emit "actual logs" and test Sentry
  as accurately as possible.
* The tests were not configured to use a non-default logging level,
  thus making it so that none of them caught the fact we were basically
  hard-coding the setting to WARNING-level.
  The tests now set the logging level to ERROR in order to make sure
  the configuration parameter works when it is non-default.
* Changes to configuration (especially ignored loggers) were leaking
  from one test into others. The tests were directly mutating the
  `odoo.tools.config.options` mapping, without resetting it afterward,
  leaving the changes in place for subsequent tests.
  Introduced a helper method `patch_config` that can be used to patch
  the config object so that the patch is undone at the end of the test.

NOTE: this commit was cherry-picked from d24f3d77a3,
and includes some changes to test code that was not in the original due
to conflicts.
2024-05-13 12:22:13 +03:00
Jon f27ae3d418 [FIX] Prevent capturing ignored exceptions 2024-05-13 12:22:13 +03:00
prabakaran d2d302cb08 [MIG] sentry: Migration to 16.0 2024-05-13 12:22:13 +03:00
Atte Isopuro 23d7203b21 [FIX] sentry: test failure due to incomplete transport init
The test code uses a "mock" Transport object to ensure that events are
stored locally in memory, instead of triggering network requests.

The Sentry client is cleaned up once done, and this triggers a call to
capture_envelope, a different way of sending events to Sentry. Since
our mock class did not fully complete initialization, and also did
not provide an overriding method, the original was called, which
depends on proper initialization to work.

We introduce an override for capture_envelope: as it is meant to be
a "sibling" to capture_event, it makes sense for us to also make sure
events registrered in this way are intercepted, even if we don't
currently expect any of our tests to explicitly cause it to be used.
2024-05-13 12:22:13 +03:00
Fernanda Hernandez f176b8bd9d [IMP] sentry: migrate sentry-raven to new api sentry-sdk 2024-05-13 12:22:13 +03:00
Travis Waelbroeck 54527d3a40 [FIX] sentry: enable use of "sentry_odoo_dir" config parameter
Allow using `sentry_release` or `sentry_odoo_dir` in the Odoo
configuration file.

Previously, the `sentry_odoo_dir` was never actually respected. It would
always be overridden by `sentry_release`. Even if `sentry_release` is
not set, it will use an empty value instead of using `sentry_odoo_dir`
to find the Git commit hash.

After this commit, the `sentry_release` parameter still takes
precedence. However, if `sentry_release` is not set and
`sentry_odoo_dir` is set, then `sentry_odoo_dir` will be used to find
the appropriate Git commit hash, which will be used as the `release`
value.

Both cases are covered by the added unit tests.
2024-05-13 12:22:13 +03:00
Ivan 4f78f32bba [IMP] sentry: black, isort 2024-05-13 12:22:13 +03:00
Simone Orsi 6681cab825 Global pylint cleanup 2024-05-13 12:22:13 +03:00
Naglis Jonaitis ca64d9c5e2 [MIG] sentry to V11
- [FIX] sentry: fixes missing `raven` library preventing loading of modules
- [FIX] 2to3 script on py file
- [FIX] add requirements.txt
2024-05-13 12:22:13 +03:00
Naglis Jonaitis a12917d37e [FIX] sentry: fixes missing `raven` library preventing loading of modules
Related: #761 #879 #881
2024-05-13 12:22:13 +03:00
Naglis Jonaitis 03c1f1b37a [ADD] sentry module (#761)
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
2024-05-13 12:22:13 +03:00