mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-10 02:47:49 +00:00
ignore opentelemetry export logs from sentry.io upload (#13232)
Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
1 parent
48ec9d1dd2
commit
061981ac54
1 file changed
+25
@@ -12,6 +12,7 @@ import sentry_sdk
|
||||
import structlog
|
||||
from djmoney.contrib.exchange.exceptions import MissingRate
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
from sentry_sdk.integrations.logging import ignore_logger
|
||||
|
||||
import InvenTree.version
|
||||
|
||||
@@ -41,10 +42,34 @@ def sentry_ignore_errors(): # pragma: no cover
|
||||
]
|
||||
|
||||
|
||||
def sentry_ignore_loggers():
|
||||
"""Return a list of logger names (fnmatch patterns) to ignore.
|
||||
|
||||
Log records from these loggers will *not* be reported to sentry.io
|
||||
(neither as events nor as breadcrumbs).
|
||||
|
||||
The OpenTelemetry exporters log at ERROR level whenever the configured
|
||||
OTLP collector is slow or unreachable (e.g. "Failed to export spans batch
|
||||
due to timeout, max retries or shutdown."). These are deployment /
|
||||
network issues with the telemetry backend, not InvenTree errors.
|
||||
"""
|
||||
return [
|
||||
# OTLP exporters (http + grpc; traces, metrics, logs)
|
||||
'opentelemetry.exporter.*',
|
||||
# Batch span / log processors ("Exception while exporting ...")
|
||||
'opentelemetry.sdk._shared_internal',
|
||||
# Periodic metric reader
|
||||
'opentelemetry.sdk.metrics._internal.export',
|
||||
]
|
||||
|
||||
|
||||
def init_sentry(dsn, sample_rate, tags, send_pii=False): # pragma: no cover
|
||||
"""Initialize sentry.io error reporting."""
|
||||
logger.info('Initializing sentry.io integration')
|
||||
|
||||
for name in sentry_ignore_loggers():
|
||||
ignore_logger(name)
|
||||
|
||||
sentry_sdk.init(
|
||||
dsn=dsn,
|
||||
integrations=[DjangoIntegration()],
|
||||
|
||||
Reference in new issue
Block a user