openverse
openverse copied to clipboard
Waveform issues are reported to Sentry twice
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:
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:
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.