File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -385,14 +385,9 @@ def _capture_envelope(envelope: Envelope) -> None:
385385 except Exception as e :
386386 logger .debug ("Can not set up continuous profiler. (%s)" , e )
387387
388- from sentry_sdk .opentelemetry .tracing import (
389- patch_readable_span ,
390- setup_sentry_tracing ,
391- )
392-
393- patch_readable_span ()
394- setup_sentry_tracing ()
388+ from sentry_sdk .opentelemetry .tracing import setup_once
395389
390+ setup_once ()
396391 logger .debug ("[Tracing] Finished setting up OpenTelemetry" )
397392 finally :
398393 _client_init_debug .set (old_debug )
Original file line number Diff line number Diff line change @@ -71,3 +71,17 @@ def setup_sentry_tracing() -> None:
7171 tracer_provider .add_span_processor (SentrySpanProcessor ()) # type: ignore[attr-defined]
7272
7373 set_global_textmap (SentryPropagator ())
74+
75+
76+ OPENTELEMETRY_SETUP_DONE = False
77+
78+
79+ def setup_once () -> None :
80+ """
81+ Makes sure opentelemetry is setup only once.
82+ """
83+ global OPENTELEMETRY_SETUP_DONE
84+ if not OPENTELEMETRY_SETUP_DONE :
85+ patch_readable_span ()
86+ setup_sentry_tracing ()
87+ OPENTELEMETRY_SETUP_DONE = True
You can’t perform that action at this time.
0 commit comments