@@ -211,16 +211,21 @@ def dummy_traces_sampler(sampling_context):
211211 pass
212212
213213
214- def test_passes_attributes_from_start_span_to_traces_sampler (
215- sentry_init , DictionaryContaining # noqa: N803
216- ):
217- traces_sampler = mock .Mock ()
214+ def test_passes_custom_attributes_in_sampling_context (sentry_init ):
215+ def traces_sampler (sampling_context ):
216+ assert sampling_context ["dog.name" ] == "Lily"
217+ assert sampling_context ["dog.activity" ] == "fetch"
218+ return 1.0
219+
218220 sentry_init (traces_sampler = traces_sampler )
219221
220- with start_span (attributes = {"dogs" : "yes" , "cats" : "maybe" }):
221- traces_sampler .assert_called_once_with (
222- DictionaryContaining ({"dogs" : "yes" , "cats" : "maybe" })
223- )
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
224229
225230
226231def test_sample_rate_affects_errors (sentry_init , capture_events ):
@@ -342,3 +347,20 @@ def dummy_profiles_sampler(sampling_context):
342347 with sentry_sdk .continue_trace ({"sentry-trace" : sentry_trace }):
343348 with sentry_sdk .start_span (name = "dogpark" , op = "op" ):
344349 pass
350+
351+
352+ def test_passes_custom_attributes_in_profiles_sampling_context (sentry_init ):
353+ def profiles_sampler (sampling_context ):
354+ assert sampling_context ["dog.name" ] == "Lily"
355+ assert sampling_context ["dog.activity" ] == "fetch"
356+ return 1.0
357+
358+ sentry_init (traces_sample_rate = 1.0 , profiles_sampler = profiles_sampler )
359+
360+ with sentry_sdk .continue_trace (
361+ {"sentry-trace" : "12312012123120121231201212312012-1121201211212012-1" }
362+ ):
363+ with sentry_sdk .start_span (
364+ name = "dogpark" , attributes = {"dog.name" : "Lily" , "dog.activity" : "fetch" }
365+ ):
366+ pass
0 commit comments