11import pytest
22
3- from unittest import mock
43from unittest .mock import MagicMock
54
65from opentelemetry .trace .propagation import get_current_span
1211 SENTRY_TRACE_KEY ,
1312)
1413from sentry_sdk .integrations .opentelemetry .propagator import SentryPropagator
15- from sentry_sdk .integrations .opentelemetry .span_processor import SentrySpanProcessor
16- from sentry_sdk .tracing_utils import Baggage
1714
1815
1916@pytest .mark .forked
@@ -23,7 +20,7 @@ def test_extract_no_context_no_sentry_trace_header():
2320 Extract should return empty context.
2421 """
2522 carrier = None
26- context = None
23+ context = {}
2724 getter = MagicMock ()
2825 getter .get .return_value = None
2926
@@ -144,8 +141,8 @@ def test_inject_continue_trace(sentry_init, SortedBaggage):
144141 with sentry_sdk .continue_trace (incoming_headers ):
145142 with sentry_sdk .start_span (name = "foo" ) as span :
146143 SentryPropagator ().inject (carrier , setter = setter )
147- assert (carrier ["sentry-trace" ]) == f"{ trace_id } -{ span .span_id } -1"
148- assert (carrier ["baggage" ]) == SortedBaggage (baggage )
144+ assert (carrier ["sentry-trace" ]) == f"{ trace_id } -{ span .span_id } -1"
145+ assert (carrier ["baggage" ]) == SortedBaggage (baggage )
149146
150147
151148def test_inject_head_sdk (sentry_init , SortedBaggage ):
@@ -156,7 +153,7 @@ def test_inject_head_sdk(sentry_init, SortedBaggage):
156153
157154 with sentry_sdk .start_span (name = "foo" ) as span :
158155 SentryPropagator ().inject (carrier , setter = setter )
159- assert (carrier ["sentry-trace" ]) == f"{ span .trace_id } -{ span .span_id } -1"
160- assert (carrier ["baggage" ]) == SortedBaggage (
156+ assert (carrier ["sentry-trace" ]) == f"{ span .trace_id } -{ span .span_id } -1"
157+ assert (carrier ["baggage" ]) == SortedBaggage (
161158 f"sentry-transaction=foo,sentry-release=release,sentry-environment=production,sentry-trace_id={ span .trace_id } ,sentry-sample_rate=1.0,sentry-sampled=true"
162159 )
0 commit comments