@@ -916,7 +916,7 @@ def test_continue_trace_no_sample_rand(sentry_init, capture_items):
916916 # traces_sample_rate=None means tracing without performance: don't make
917917 # any sampling decisions; defer downstream
918918 None ,
919- )
919+ ),
920920)
921921def test_outgoing_traceparent_and_baggage_head_sdk (sentry_init , traces_sample_rate ):
922922 sentry_init (
@@ -945,7 +945,11 @@ def test_outgoing_traceparent_and_baggage_head_sdk(sentry_init, traces_sample_ra
945945 span_id = span .span_id
946946 assert traceparent == f"{ trace_id } -{ span_id } -0"
947947 elif expected_sampled is None :
948- span_id = sentry_sdk .get_isolation_scope ().get_active_propagation_context ().span_id
948+ span_id = (
949+ sentry_sdk .get_isolation_scope ()
950+ .get_active_propagation_context ()
951+ .span_id
952+ )
949953 assert traceparent == f"{ trace_id } -{ span_id } "
950954
951955 baggage = sentry_sdk .get_baggage ()
@@ -976,9 +980,11 @@ def test_outgoing_traceparent_and_baggage_head_sdk(sentry_init, traces_sample_ra
976980 # any sampling decisions on our end, propagate existing ones
977981 (None , False ),
978982 (None , True ),
979- )
983+ ),
980984)
981- def test_outgoing_traceparent_and_baggage_incoming_trace (sentry_init , traces_sample_rate , parent_sampled ):
985+ def test_outgoing_traceparent_and_baggage_incoming_trace (
986+ sentry_init , traces_sample_rate , parent_sampled
987+ ):
982988 """The SDK respects a positive/negative incoming sampling decision."""
983989 sentry_init (
984990 traces_sample_rate = traces_sample_rate ,
@@ -994,23 +1000,29 @@ def test_outgoing_traceparent_and_baggage_incoming_trace(sentry_init, traces_sam
9941000
9951001 if parent_sampled is True :
9961002 incoming_sentry_trace = f"{ trace_id } -{ parent_span_id } -1"
997- incoming_baggage .update ({
998- "sentry-sample_rate" : "0.75" ,
999- "sentry-sample_rand" : "0.500000" ,
1000- "sentry-sampled" : "true" ,
1001- })
1003+ incoming_baggage .update (
1004+ {
1005+ "sentry-sample_rate" : "0.75" ,
1006+ "sentry-sample_rand" : "0.500000" ,
1007+ "sentry-sampled" : "true" ,
1008+ }
1009+ )
10021010 elif parent_sampled is False :
10031011 incoming_sentry_trace = f"{ trace_id } -{ parent_span_id } -0"
1004- incoming_baggage .update ({
1005- "sentry-sample_rate" : "0.75" ,
1006- "sentry-sample_rand" : "0.800000" ,
1007- "sentry-sampled" : "false" ,
1008- })
1012+ incoming_baggage .update (
1013+ {
1014+ "sentry-sample_rate" : "0.75" ,
1015+ "sentry-sample_rand" : "0.800000" ,
1016+ "sentry-sampled" : "false" ,
1017+ }
1018+ )
10091019
10101020 sentry_sdk .traces .continue_trace (
10111021 {
10121022 "sentry-trace" : incoming_sentry_trace ,
1013- "baggage" : "," .join (sorted ([f"{ k } ={ v } " for k ,v in incoming_baggage .items ()])),
1023+ "baggage" : "," .join (
1024+ sorted ([f"{ k } ={ v } " for k , v in incoming_baggage .items ()])
1025+ ),
10141026 }
10151027 )
10161028
@@ -1024,7 +1036,9 @@ def test_outgoing_traceparent_and_baggage_incoming_trace(sentry_init, traces_sam
10241036 # (it doesn't even make sense to start a span explicitly as we do in
10251037 # this test since tracing is turned off, but nothing should break
10261038 # either)
1027- span_id = sentry_sdk .get_current_scope ().get_active_propagation_context ().span_id
1039+ span_id = (
1040+ sentry_sdk .get_current_scope ().get_active_propagation_context ().span_id
1041+ )
10281042 assert traceparent == f"{ trace_id } -{ span_id } "
10291043 else :
10301044 span_id = span .span_id
@@ -1048,9 +1062,11 @@ def test_outgoing_traceparent_and_baggage_incoming_trace(sentry_init, traces_sam
10481062 # traces_sample_rate=None means tracing without performance: don't make
10491063 # any sampling decisions on our end, propagate existing ones
10501064 None ,
1051- )
1065+ ),
10521066)
1053- def test_outgoing_traceparent_and_baggage_incoming_trace_deferred (sentry_init , traces_sample_rate ):
1067+ def test_outgoing_traceparent_and_baggage_incoming_trace_deferred (
1068+ sentry_init , traces_sample_rate
1069+ ):
10541070 """The SDK handles a deferred incoming sampling decision correctly."""
10551071 sentry_init (
10561072 traces_sample_rate = traces_sample_rate ,
@@ -1067,15 +1083,14 @@ def test_outgoing_traceparent_and_baggage_incoming_trace_deferred(sentry_init, t
10671083 trace_id = "0af7651916cd43dd8448eb211c80319c"
10681084 parent_span_id = "b7ad6b7169203331"
10691085
1070- incoming_baggage = {
1071- "sentry-trace_id" : trace_id ,
1072- "sentry-sample_rand" : "0.500000"
1073- }
1086+ incoming_baggage = {"sentry-trace_id" : trace_id , "sentry-sample_rand" : "0.500000" }
10741087
10751088 sentry_sdk .traces .continue_trace (
10761089 {
10771090 "sentry-trace" : f"{ trace_id } -{ parent_span_id } -" ,
1078- "baggage" : "," .join (sorted ([f"{ k } ={ v } " for k ,v in incoming_baggage .items ()])),
1091+ "baggage" : "," .join (
1092+ sorted ([f"{ k } ={ v } " for k , v in incoming_baggage .items ()])
1093+ ),
10791094 }
10801095 )
10811096
@@ -1089,7 +1104,9 @@ def test_outgoing_traceparent_and_baggage_incoming_trace_deferred(sentry_init, t
10891104 # (it doesn't even make sense to start a span explicitly as we do in
10901105 # this test since tracing is turned off, but nothing should break
10911106 # either)
1092- span_id = sentry_sdk .get_current_scope ().get_active_propagation_context ().span_id
1107+ span_id = (
1108+ sentry_sdk .get_current_scope ().get_active_propagation_context ().span_id
1109+ )
10931110 else :
10941111 span_id = span .span_id
10951112
@@ -1107,10 +1124,12 @@ def test_outgoing_traceparent_and_baggage_incoming_trace_deferred(sentry_init, t
11071124 # If our sample rate is not None, we're expected to have made
11081125 # a sampling decision
11091126 expected_baggage = incoming_baggage
1110- expected_baggage .update ({
1111- "sentry-sample_rate" : str (traces_sample_rate ),
1112- "sentry-sampled" : "true" if expected_sampled else "false" ,
1113- })
1127+ expected_baggage .update (
1128+ {
1129+ "sentry-sample_rate" : str (traces_sample_rate ),
1130+ "sentry-sampled" : "true" if expected_sampled else "false" ,
1131+ }
1132+ )
11141133 assert baggage_items == expected_baggage
11151134 else :
11161135 # If tracing is off, we should have deferred the decision further
0 commit comments