Skip to content

Conversation

@aisopuro
Copy link
Contributor

Migration itself is not particularly notable. However there are some oddities in this PR:

  • Based on the 16.0 branch as usual, up until commit af35006
  • Then cherry-picked a fix from 15 that apparently had not made it to 16. Commits fbfa2e5 and 9213ab1
  • Pre-commit was not able to automatically fix everything, so made some manual fixes in a separate commit

@aisopuro
Copy link
Contributor Author

@moylop260 , @fernandahf and/or @naglis I understand you're the maintainers of the sentry module. My PR seems to be alright except for some code coverage checks failing. Most of the failures seem to be from various helper functions that seem fairly complicated to test.

I wanted to ask if you had any idea how I should improve the coverage: would it be OK for me to either tell coverage to ignore certain functions altogether, or can I improve the coverage of a different module in this same PR to make the tests pass?

Thanks in advance. I hope to be able to work on this if I can just get some guidance, I don't want this PR to grow stale.

@StefanRijnhart StefanRijnhart mentioned this pull request Feb 2, 2024
Copy link

@thomaspaulb thomaspaulb left a comment

Choose a reason for hiding this comment

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

I don't think coverage changes are blocking on migration PR's.

@aisopuro
Copy link
Contributor Author

aisopuro commented Feb 5, 2024

Rebased to resolve conflicts in requirements.txt (another PR was merged that also auto-generated it).

@aisopuro aisopuro force-pushed the 17.0-mig-sentry branch 6 times, most recently from fe24361 to 66619be Compare February 5, 2024 14:15
@aisopuro
Copy link
Contributor Author

aisopuro commented Feb 5, 2024

OK, looks like I had forgotten to import the test files 😓 . All checks are green now.

Copy link
Member

@atchuthan atchuthan left a comment

Choose a reason for hiding this comment

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

👍

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@thomaspaulb
Copy link

/ocabot migration sentry

/ocabot merge nobump

@OCA-git-bot OCA-git-bot added this to the 17.0 milestone May 6, 2024
@OCA-git-bot OCA-git-bot mentioned this pull request May 6, 2024
38 tasks
@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 17.0-ocabot-merge-pr-2818-by-thomaspaulb-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request May 6, 2024
Signed-off-by thomaspaulb
@OCA-git-bot
Copy link
Contributor

@thomaspaulb your merge command was aborted due to failed check(s), which you can inspect on this commit of 17.0-ocabot-merge-pr-2818-by-thomaspaulb-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

naglis and others added 2 commits May 13, 2024 12:22
* [ADD] sentry module

* [FIX] updated sentry module according to PR comments
aisopuro and others added 22 commits May 13, 2024 12:22
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.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-15.0/server-tools-15.0-sentry
Translate-URL: https://translation.odoo-community.org/projects/server-tools-15-0/server-tools-15-0-sentry/
Currently, version 1.17.0 of sentry_sdk is causing the following error:

SentryOption("with_locals", DEFAULT_OPTIONS["with_locals"], None),
KeyError: 'with_locals'.

Where the with_locals key is not found in the dictionary, generating an
error, stopping the installation of the sentry module.

In version 1.17.0 rename 'with_locals'  to 'include_local_variables'
getsentry/sentry-python@79e3316

This commit adjust the  get_sentry_options() method in
https://github.com/Vauxoo/server-tools/blob/16.0/sentry/const.py file, set the new variable.
Odoo requires urllib3 == 1.26.5
https://github.com/Vauxoo/odoo/blob/e0feda462961ae612cacc36d1a75d56c5594fd22/requirements.txt#L56

sentry-sdk > 1.9.0 required urllib3 >= 1.26.11
https://github.com/getsentry/sentry-python/blob/4f1f782fbedc9adcf1dfcd2092bb328443f09e8c/setup.py#L43

Currently, urllib3 >= 1.26.11 is causing the following error in
response.py:

``` Traceback (most recent call last):
"/home/odoo/.local/lib/python3.8/site-packages/urllib3/response.py",
line 705, in _error_catcher
    yield
  File
"/home/odoo/.local/lib/python3.8/site-packages/urllib3/response.py",
line 830, in _raw_read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
urllib3.exceptions.IncompleteRead: IncompleteRead(1501 bytes read, -827
more expected)
```

On the other hand, sentry 1.9.0 supports urllib3 >= 1.10.0, satisfying
odoo requirements.

This partially reverts
OCA@d7ae024.
That was initially introduced to support newer versions of `sentry_sdk`, but won't be required anymore
due to this downgrade.
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 d24f3d7,
and includes some changes to test code that was not in the original due
to conflicts.
@thomaspaulb
Copy link

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 17.0-ocabot-merge-pr-2818-by-thomaspaulb-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 9bdb059 into OCA:17.0 May 14, 2024
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 33d7a8e. Thanks a lot for contributing to OCA. ❤️

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.