@@ -121,7 +121,7 @@ def test_span_sampled_when_created(sentry_init, capture_envelopes):
121121 # at start_span() time
122122
123123 def traces_sampler (sampling_context ):
124- assert "delayed_attribute" not in sampling_context ["span " ]["attributes" ]
124+ assert "delayed_attribute" not in sampling_context ["span_context " ]["attributes" ]
125125 return 1.0
126126
127127 sentry_init (
@@ -170,9 +170,11 @@ def test_start_span_attributes(sentry_init, capture_envelopes):
170170
171171def test_start_span_attributes_in_traces_sampler (sentry_init , capture_envelopes ):
172172 def traces_sampler (sampling_context ):
173- assert "attributes" in sampling_context ["span" ]
174- assert "my_attribute" in sampling_context ["span" ]["attributes" ]
175- assert sampling_context ["span" ]["attributes" ]["my_attribute" ] == "my_value"
173+ assert "attributes" in sampling_context ["span_context" ]
174+ assert "my_attribute" in sampling_context ["span_context" ]["attributes" ]
175+ assert (
176+ sampling_context ["span_context" ]["attributes" ]["my_attribute" ] == "my_value"
177+ )
176178 return 1.0
177179
178180 sentry_init (
@@ -203,16 +205,16 @@ def test_sampling_context(sentry_init, capture_envelopes):
203205 def traces_sampler (sampling_context ):
204206 nonlocal received_trace_id
205207
206- assert "trace_id" in sampling_context ["span " ]
207- received_trace_id = sampling_context ["span " ]["trace_id" ]
208+ assert "trace_id" in sampling_context ["span_context " ]
209+ received_trace_id = sampling_context ["span_context " ]["trace_id" ]
208210
209- assert "parent_span_id" in sampling_context ["span " ]
210- assert sampling_context ["span " ]["parent_span_id" ] is None
211+ assert "parent_span_id" in sampling_context ["span_context " ]
212+ assert sampling_context ["span_context " ]["parent_span_id" ] is None
211213
212- assert "parent_sampled" in sampling_context ["span " ]
213- assert sampling_context ["span " ]["parent_sampled" ] is None
214+ assert "parent_sampled" in sampling_context ["span_context " ]
215+ assert sampling_context ["span_context " ]["parent_sampled" ] is None
214216
215- assert "attributes" in sampling_context ["span " ]
217+ assert "attributes" in sampling_context ["span_context " ]
216218
217219 return 1.0
218220
@@ -264,7 +266,7 @@ def traces_sampler(sampling_context):
264266
265267def test_custom_sampling_context_update_to_context_value_persists (sentry_init ):
266268 def traces_sampler (sampling_context ):
267- if sampling_context ["span " ]["attributes" ]["first" ] is True :
269+ if sampling_context ["span_context " ]["attributes" ]["first" ] is True :
268270 assert sampling_context ["custom_value" ] == 1
269271 else :
270272 assert sampling_context ["custom_value" ] == 2
@@ -362,10 +364,10 @@ class Class:
362364
363365def test_traces_sampler_drops_span (sentry_init , capture_envelopes ):
364366 def traces_sampler (sampling_context ):
365- assert "attributes" in sampling_context ["span " ]
366- assert "drop" in sampling_context ["span " ]["attributes" ]
367+ assert "attributes" in sampling_context ["span_context " ]
368+ assert "drop" in sampling_context ["span_context " ]["attributes" ]
367369
368- if sampling_context ["span " ]["attributes" ]["drop" ] is True :
370+ if sampling_context ["span_context " ]["attributes" ]["drop" ] is True :
369371 return 0.0
370372
371373 return 1.0
@@ -399,7 +401,7 @@ def test_traces_sampler_called_once_per_segment(sentry_init):
399401 def traces_sampler (sampling_context ):
400402 nonlocal traces_sampler_called , span_name_in_traces_sampler
401403 traces_sampler_called += 1
402- span_name_in_traces_sampler = sampling_context ["span " ]["name" ]
404+ span_name_in_traces_sampler = sampling_context ["span_context " ]["name" ]
403405 return 1.0
404406
405407 sentry_init (
0 commit comments