2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +00:00

Prevent sentry reporting in test mode (#9304)

This commit is contained in:
Oliver 2025-03-15 22:42:18 +11:00 committed by GitHub
parent f1cf78e9a1
commit cdb445583b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -66,6 +66,10 @@ def init_sentry(dsn, sample_rate, tags):
def report_exception(exc):
"""Report an exception to sentry.io."""
if settings.TESTING:
# Skip reporting exceptions in testing mode
return
if settings.SENTRY_ENABLED and settings.SENTRY_DSN:
if not any(isinstance(exc, e) for e in sentry_ignore_errors()):
logger.info('Reporting exception to sentry.io: %s', exc)

View File

@ -792,7 +792,7 @@ SENTRY_SAMPLE_RATE = float(
get_setting('INVENTREE_SENTRY_SAMPLE_RATE', 'sentry_sample_rate', 0.1)
)
if SENTRY_ENABLED and SENTRY_DSN: # pragma: no cover
if SENTRY_ENABLED and SENTRY_DSN and not TESTING: # pragma: no cover
init_sentry(SENTRY_DSN, SENTRY_SAMPLE_RATE, inventree_tags)
# OpenTelemetry tracing