@@ -120,7 +120,7 @@ def test_span_sampled_when_created(sentry_init, capture_envelopes):
120120 # at start_span() time
121121
122122 def traces_sampler (sampling_context ):
123- assert "delayed_attribute" not in sampling_context ["span " ]["attributes" ]
123+ assert "delayed_attribute" not in sampling_context ["span_context " ]["attributes" ]
124124 return 1.0
125125
126126 sentry_init (
@@ -169,9 +169,11 @@ def test_start_span_attributes(sentry_init, capture_envelopes):
169169
170170def test_start_span_attributes_in_traces_sampler (sentry_init , capture_envelopes ):
171171 def traces_sampler (sampling_context ):
172- assert "attributes" in sampling_context ["span" ]
173- assert "my_attribute" in sampling_context ["span" ]["attributes" ]
174- assert sampling_context ["span" ]["attributes" ]["my_attribute" ] == "my_value"
172+ assert "attributes" in sampling_context ["span_context" ]
173+ assert "my_attribute" in sampling_context ["span_context" ]["attributes" ]
174+ assert (
175+ sampling_context ["span_context" ]["attributes" ]["my_attribute" ] == "my_value"
176+ )
175177 return 1.0
176178
177179 sentry_init (
@@ -202,16 +204,16 @@ def test_sampling_context(sentry_init, capture_envelopes):
202204 def traces_sampler (sampling_context ):
203205 nonlocal received_trace_id
204206
205- assert "trace_id" in sampling_context ["span " ]
206- received_trace_id = sampling_context ["span " ]["trace_id" ]
207+ assert "trace_id" in sampling_context ["span_context " ]
208+ received_trace_id = sampling_context ["span_context " ]["trace_id" ]
207209
208- assert "parent_span_id" in sampling_context ["span " ]
209- assert sampling_context ["span " ]["parent_span_id" ] is None
210+ assert "parent_span_id" in sampling_context ["span_context " ]
211+ assert sampling_context ["span_context " ]["parent_span_id" ] is None
210212
211- assert "parent_sampled" in sampling_context ["span " ]
212- assert sampling_context ["span " ]["parent_sampled" ] is None
213+ assert "parent_sampled" in sampling_context ["span_context " ]
214+ assert sampling_context ["span_context " ]["parent_sampled" ] is None
213215
214- assert "attributes" in sampling_context ["span " ]
216+ assert "attributes" in sampling_context ["span_context " ]
215217
216218 return 1.0
217219
@@ -263,7 +265,7 @@ def traces_sampler(sampling_context):
263265
264266def test_custom_sampling_context_update_to_context_value_persists (sentry_init ):
265267 def traces_sampler (sampling_context ):
266- if sampling_context ["span " ]["attributes" ]["first" ] is True :
268+ if sampling_context ["span_context " ]["attributes" ]["first" ] is True :
267269 assert sampling_context ["custom_value" ] == 1
268270 else :
269271 assert sampling_context ["custom_value" ] == 2
@@ -361,10 +363,10 @@ class Class:
361363
362364def test_traces_sampler_drops_span (sentry_init , capture_envelopes ):
363365 def traces_sampler (sampling_context ):
364- assert "attributes" in sampling_context ["span " ]
365- assert "drop" in sampling_context ["span " ]["attributes" ]
366+ assert "attributes" in sampling_context ["span_context " ]
367+ assert "drop" in sampling_context ["span_context " ]["attributes" ]
366368
367- if sampling_context ["span " ]["attributes" ]["drop" ] is True :
369+ if sampling_context ["span_context " ]["attributes" ]["drop" ] is True :
368370 return 0.0
369371
370372 return 1.0
@@ -398,7 +400,7 @@ def test_traces_sampler_called_once_per_segment(sentry_init):
398400 def traces_sampler (sampling_context ):
399401 nonlocal traces_sampler_called , span_name_in_traces_sampler
400402 traces_sampler_called += 1
401- span_name_in_traces_sampler = sampling_context ["span " ]["name" ]
403+ span_name_in_traces_sampler = sampling_context ["span_context " ]["name" ]
402404 return 1.0
403405
404406 sentry_init (
0 commit comments