|
4 | 4 | from datetime import datetime
|
5 | 5 | from contextlib import contextmanager
|
6 | 6 |
|
| 7 | +from sentry_sdk.api import get_traceparent, get_baggage |
7 | 8 | from sentry_sdk._compat import with_metaclass
|
8 | 9 | from sentry_sdk.consts import INSTRUMENTER
|
9 | 10 | from sentry_sdk.scope import Scope
|
10 | 11 | from sentry_sdk.client import Client
|
11 | 12 | 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 | +) |
13 | 20 | from sentry_sdk.session import Session
|
14 | 21 | from sentry_sdk.tracing_utils import has_tracing_enabled
|
15 | 22 | from sentry_sdk.utils import (
|
@@ -723,13 +730,26 @@ def iter_trace_propagation_headers(self, span=None):
|
723 | 730 | def trace_propagation_meta(self, span=None):
|
724 | 731 | # type: (Optional[Span]) -> str
|
725 | 732 | """
|
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. |
728 | 735 | """
|
| 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 | + |
729 | 741 | meta = ""
|
730 | 742 |
|
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) |
733 | 753 |
|
734 | 754 | return meta
|
735 | 755 |
|
|
0 commit comments