1
0
mirror of https://github.com/quay/quay.git synced 2025-11-16 11:42:27 +03:00

fix: resolve Sentry/OpenTelemetry integration conflicts (PROJQUAY-9198) (#4232)

* fix: resolve Sentry/OpenTelemetry integration conflicts

Configure Sentry to use minimal integrations when OTEL_TRACING is enabled
to prevent instrumentation conflicts that broke exception capture


---------

Co-authored-by: shudeshp <shudeshp@redhat.com>
This commit is contained in:
Shubhra Deshpande
2025-09-04 16:19:27 -04:00
committed by GitHub
parent c843bf2104
commit d0f45f545a
7 changed files with 174 additions and 42 deletions

View File

@@ -1,6 +1,12 @@
import logging
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
from sentry_sdk.integrations.stdlib import StdlibIntegration
import features
class FakeSentryClient(object):
@@ -31,11 +37,36 @@ class Sentry(object):
sentry_dsn = app.config.get("SENTRY_DSN", "")
if sentry_dsn:
try:
integrations = []
# Always include logging integration
integrations.append(
LoggingIntegration(level=logging.INFO, event_level=logging.ERROR)
)
# Only add Flask and SQLAlchemy integrations if OpenTelemetry is not enabled
# to avoid conflicts with OpenTelemetry instrumentors
if not getattr(features, "OTEL_TRACING", False):
integrations.extend(
[
FlaskIntegration(transaction_style="endpoint"),
SqlalchemyIntegration(),
StdlibIntegration(),
]
)
else:
# When OTEL is enabled, use minimal integrations to avoid conflicts
logger = logging.getLogger(__name__)
logger.info("OpenTelemetry enabled - using minimal Sentry integrations")
initialized_sentry = sentry_sdk.init(
dsn=sentry_dsn,
environment=app.config.get("SENTRY_ENVIRONMENT", "production"),
traces_sample_rate=app.config.get("SENTRY_TRACES_SAMPLE_RATE", 0.1),
profiles_sample_rate=app.config.get("SENTRY_PROFILES_SAMPLE_RATE", 0.1),
integrations=integrations,
default_integrations=False,
auto_session_tracking=True,
)
# Return the initialized Sentry SDK object directly
sentry = initialized_sentry