Skip to content

Commit 20073a7

Browse files
committed
Updated trace_propagation_meta to use new top level api
1 parent 8b505a1 commit 20073a7

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

sentry_sdk/hub.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
from datetime import datetime
55
from contextlib import contextmanager
66

7+
from sentry_sdk.api import get_traceparent, get_baggage
78
from sentry_sdk._compat import with_metaclass
89
from sentry_sdk.consts import INSTRUMENTER
910
from sentry_sdk.scope import Scope
1011
from sentry_sdk.client import Client
1112
from sentry_sdk.profiler import Profile
12-
from sentry_sdk.tracing import NoOpSpan, Span, Transaction
13+
from sentry_sdk.tracing import (
14+
NoOpSpan,
15+
Span,
16+
Transaction,
17+
BAGGAGE_HEADER_NAME,
18+
SENTRY_TRACE_HEADER_NAME,
19+
)
1320
from sentry_sdk.session import Session
1421
from sentry_sdk.tracing_utils import has_tracing_enabled
1522
from sentry_sdk.utils import (
@@ -723,13 +730,26 @@ def iter_trace_propagation_headers(self, span=None):
723730
def trace_propagation_meta(self, span=None):
724731
# type: (Optional[Span]) -> str
725732
"""
726-
Return meta tags which should be injected into the HTML template
727-
to allow propagation of trace data.
733+
Return meta tags which should be injected into HTML templates
734+
to allow propagation of trace information.
728735
"""
736+
if span is None:
737+
logger.warning(
738+
"The parameter `span` in trace_propagation_meta() is deprecated and will be removed in the future."
739+
)
740+
729741
meta = ""
730742

731-
for name, content in self.iter_trace_propagation_headers(span):
732-
meta += '<meta name="%s" content="%s">' % (name, content)
743+
sentry_trace = get_traceparent()
744+
if sentry_trace is not None:
745+
meta += '<meta name="%s" content="%s">' % (
746+
SENTRY_TRACE_HEADER_NAME,
747+
sentry_trace,
748+
)
749+
750+
baggage = get_baggage()
751+
if baggage is not None:
752+
meta += '<meta name="%s" content="%s">' % (BAGGAGE_HEADER_NAME, baggage)
733753

734754
return meta
735755

0 commit comments

Comments
 (0)