openverse icon indicating copy to clipboard operation
openverse copied to clipboard

Waveform issues are reported to Sentry twice

Open obulat opened this issue 7 months ago • 0 comments

Description

We call both logger.error and sentry_sdk.capture_exception for all errors during waveform generation:

https://github.com/WordPress/openverse/blob/7cfb689b20e08d4dfc2b2ac31051ea21b558184b/api/api/utils/waveform.py#L120-L121

Both of these calls send the error to Sentry: Screenshot 2024-07-23 at 12 46 11 PM

The logger.error shows where the error was generated in the code:

{'file_name': 'audio-e0742ff3-f909-4e1d-9555-8e6399157452.mp3', 'e': CalledProcessError(1, ['audiowaveform', '--input-filename', 'audio-e0742ff3-f909-4e1d-9555-8e6399157452.mp3', '--output-format', 'json', '--pixels-per-second', '22223']), 'event': 'waveform_generation_failed', 'timestamp': '2024-07-22T05:49:08.862359Z', 'request_id': '', 'ip': 'xx.xx.xx.xx', 'logger': 'api.utils.waveform', 'level': 'error', 'lineno': 120, 'func_name': 'generate_waveform', 'filename': 'waveform.py'}

However, it's easier to understand and handle the stack trace from the sentry_sdk.capture_exception call in Sentry UI:

Screenshot 2024-07-23 at 12 47 05 PM

Additional context

To solve this, we can drop the capture_exception call. In this case, it would be nice to make the logger.error calls show the stack trace in the Sentry UI. Another solution would be to add a child logger to this module that is ignored by Sentry, and only use the capture_exception results.

The changes were introduced in #4444.

obulat avatar Jul 23 '24 09:07 obulat