@@ -211,6 +211,23 @@ def dummy_traces_sampler(sampling_context):
211211 pass
212212
213213
214+ def test_passes_custom_attributes_in_sampling_context (sentry_init ):
215+ def dummy_traces_sampler (sampling_context ):
216+ assert sampling_context ["dog.name" ] == "Lily"
217+ assert sampling_context ["dog.activity" ] == "fetch"
218+ return 1.0
219+
220+ sentry_init (traces_sample_rate = 1.0 , traces_sampler = dummy_traces_sampler )
221+
222+ with sentry_sdk .continue_trace (
223+ {"sentry-trace" : "12312012123120121231201212312012-1121201211212012-1" }
224+ ):
225+ with sentry_sdk .start_span (
226+ name = "dogpark" , attributes = {"dog.name" : "Lily" , "dog.activity" : "fetch" }
227+ ):
228+ pass
229+
230+
214231def test_passes_attributes_from_start_span_to_traces_sampler (
215232 sentry_init , DictionaryContaining # noqa: N803
216233):
@@ -342,3 +359,20 @@ def dummy_profiles_sampler(sampling_context):
342359 with sentry_sdk .continue_trace ({"sentry-trace" : sentry_trace }):
343360 with sentry_sdk .start_span (name = "dogpark" , op = "op" ):
344361 pass
362+
363+
364+ def test_passes_custom_attributes_in_profiles_sampling_context (sentry_init ):
365+ def profiles_sampler (sampling_context ):
366+ assert sampling_context ["dog.name" ] == "Lily"
367+ assert sampling_context ["dog.activity" ] == "fetch"
368+ return 1.0
369+
370+ sentry_init (traces_sample_rate = 1.0 , profiles_sampler = profiles_sampler )
371+
372+ with sentry_sdk .continue_trace (
373+ {"sentry-trace" : "12312012123120121231201212312012-1121201211212012-1" }
374+ ):
375+ with sentry_sdk .start_span (
376+ name = "dogpark" , attributes = {"dog.name" : "Lily" , "dog.activity" : "fetch" }
377+ ):
378+ pass
0 commit comments