Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Inclusion of weblate logs in Sentry configurable #4673

Closed
iBurnette opened this issue Oct 9, 2020 · 4 comments
Closed

Make Inclusion of weblate logs in Sentry configurable #4673

iBurnette opened this issue Oct 9, 2020 · 4 comments
Assignees
Labels
enhancement Adding or requesting a new feature.
Milestone

Comments

@iBurnette
Copy link

Is your feature request related to a problem? Please describe.
We would like to use Sentry to monitor events generated by weblate. It appears that the sentry sdk is currently configured to ignore the weblate and weblate.celery loggers. As a result, the Sentry data paints and incomplete picture.

Describe the solution you'd like
A config variable is introduced which allows users to choose whether or not data from the weblate and weblate.celery loggers is sent to Sentry.

Describe alternatives you've considered
We have considered forwarding log data to Sentry using a separate process, but we have been unable to find the logs in their default locations (However, it is possible that they were configured to appear elsewhere, the developer who configured the pod is out sick today).

Additional context
Above the code in question (weblate/utils/errors.py:93-5), there is a comment:

Ignore Weblate logging, those should be reported as proper errors

It is not immediately clear why data sent to Sentry could not also be reported as an error. In fact, your own documentation suggests using Sentry to monitor weblate and celery errors, and yet both of these loggers are explicitly being ignored. What exactly does "built-in support" mean in this context?

@nijel
Copy link
Member

nijel commented Oct 9, 2020

The reason for this is that errors are sent to Sentry as an exception and logged. The log then needs to be ignored for Sentry to avoid duplication of all such errors.

@iBurnette
Copy link
Author

@nijel just to make sure I understand you, the current Sentry workflow is this:

  1. Some issue is detected, prompting the "weblate" logger to write some data to the logs, and an exception to be raised
  2. Eventually, this exception is caught by Django, which returns an appropriate HTTP error response.

Sentry has been set to ignore the "weblate" logger because otherwise both of these steps would produce a Sentry entry, so a single issue would be represented multiple times.

Is my understanding correct?

@nijel
Copy link
Member

nijel commented Oct 12, 2020

To be more precise let's look at the code:

if not skip_sentry and settings.SENTRY_DSN:
with sentry_sdk.push_scope() as scope:
if extra_data:
for key, value in extra_data.items():
scope.set_extra(key, value)
scope.set_extra("error_cause", cause)
scope.level = level
sentry_sdk.capture_exception()
log = getattr(logger, level)
error = sys.exc_info()[1]
log("%s: %s: %s", cause, error.__class__.__name__, force_str(error))

The exception is sent to Sentry (if configured, lines 59-66) and logged (line 72).

You don't want both to appear in Sentry as that will create two distinct events there. On the other side the error should appear in the log even when using Sentry to make logging consistent with non-Sentry setup and to allow to see things locally on the system.

What could be way to improve it is to use dedicated logger for this kind of logs and ignore only that for Sentry.

@nijel nijel added the enhancement Adding or requesting a new feature. label Oct 13, 2020
@nijel nijel self-assigned this Oct 13, 2020
@nijel nijel added this to the 4.3 milestone Oct 13, 2020
@nijel nijel closed this as completed in 82160cd Oct 13, 2020
@github-actions
Copy link

Thank you for your report, the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, consider supporting Weblate by donating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants