@@ -733,10 +733,11 @@ def test_outgoing_trace_headers_span_streaming(
733733
734734 items = capture_items ("span" )
735735
736- if asyncio .iscoroutinefunction (httpx2_client .get ):
737- response = asyncio .run (httpx2_client .get (url ))
738- else :
739- response = httpx2_client .get (url )
736+ with sentry_sdk .traces .start_span (name = "test" ):
737+ if asyncio .iscoroutinefunction (httpx2_client .get ):
738+ response = asyncio .run (httpx2_client .get (url ))
739+ else :
740+ response = httpx2_client .get (url )
740741
741742 sentry_sdk .flush ()
742743
@@ -775,12 +776,13 @@ def test_outgoing_trace_headers_append_to_baggage_span_streaming(
775776 items = capture_items ("span" )
776777
777778 with mock .patch ("sentry_sdk.tracing_utils.Random.randrange" , return_value = 500000 ):
778- if asyncio .iscoroutinefunction (httpx2_client .get ):
779- response = asyncio .run (
780- httpx2_client .get (url , headers = {"baGGage" : "custom=data" })
781- )
782- else :
783- response = httpx2_client .get (url , headers = {"baGGage" : "custom=data" })
779+ with sentry_sdk .traces .start_span (name = "test" ):
780+ if asyncio .iscoroutinefunction (httpx2_client .get ):
781+ response = asyncio .run (
782+ httpx2_client .get (url , headers = {"baGGage" : "custom=data" })
783+ )
784+ else :
785+ response = httpx2_client .get (url , headers = {"baGGage" : "custom=data" })
784786
785787 sentry_sdk .flush ()
786788
@@ -814,10 +816,11 @@ def test_request_source_disabled_span_streaming(
814816
815817 url = "http://example.com/"
816818
817- if asyncio .iscoroutinefunction (httpx2_client .get ):
818- asyncio .run (httpx2_client .get (url ))
819- else :
820- httpx2_client .get (url )
819+ with sentry_sdk .traces .start_span (name = "test" ):
820+ if asyncio .iscoroutinefunction (httpx2_client .get ):
821+ asyncio .run (httpx2_client .get (url ))
822+ else :
823+ httpx2_client .get (url )
821824
822825 sentry_sdk .flush ()
823826
@@ -858,10 +861,11 @@ def test_request_source_enabled_span_streaming(
858861
859862 url = "http://example.com/"
860863
861- if asyncio .iscoroutinefunction (httpx2_client .get ):
862- asyncio .run (httpx2_client .get (url ))
863- else :
864- httpx2_client .get (url )
864+ with sentry_sdk .traces .start_span (name = "test" ):
865+ if asyncio .iscoroutinefunction (httpx2_client .get ):
866+ asyncio .run (httpx2_client .get (url ))
867+ else :
868+ httpx2_client .get (url )
865869
866870 sentry_sdk .flush ()
867871
@@ -894,10 +898,11 @@ def test_request_source_span_streaming(
894898
895899 url = "http://example.com/"
896900
897- if asyncio .iscoroutinefunction (httpx2_client .get ):
898- asyncio .run (httpx2_client .get (url ))
899- else :
900- httpx2_client .get (url )
901+ with sentry_sdk .traces .start_span (name = "test" ):
902+ if asyncio .iscoroutinefunction (httpx2_client .get ):
903+ asyncio .run (httpx2_client .get (url ))
904+ else :
905+ httpx2_client .get (url )
901906
902907 sentry_sdk .flush ()
903908
@@ -951,14 +956,15 @@ def test_request_source_with_module_in_search_path_span_streaming(
951956
952957 url = "http://example.com/"
953958
954- if asyncio .iscoroutinefunction (httpx2_client .get ):
955- from httpx2_helpers .helpers import async_get_request_with_client
959+ with sentry_sdk .traces .start_span (name = "test" ):
960+ if asyncio .iscoroutinefunction (httpx2_client .get ):
961+ from httpx2_helpers .helpers import async_get_request_with_client
956962
957- asyncio .run (async_get_request_with_client (httpx2_client , url ))
958- else :
959- from httpx2_helpers .helpers import get_request_with_client
963+ asyncio .run (async_get_request_with_client (httpx2_client , url ))
964+ else :
965+ from httpx2_helpers .helpers import get_request_with_client
960966
961- get_request_with_client (httpx2_client , url )
967+ get_request_with_client (httpx2_client , url )
962968
963969 sentry_sdk .flush ()
964970
@@ -1010,10 +1016,11 @@ def test_no_request_source_if_duration_too_short_span_streaming(
10101016
10111017 url = "http://example.com/"
10121018
1013- if asyncio .iscoroutinefunction (httpx2_client .get ):
1014- asyncio .run (httpx2_client .get (url ))
1015- else :
1016- httpx2_client .get (url )
1019+ with sentry_sdk .traces .start_span (name = "test" ):
1020+ if asyncio .iscoroutinefunction (httpx2_client .get ):
1021+ asyncio .run (httpx2_client .get (url ))
1022+ else :
1023+ httpx2_client .get (url )
10171024
10181025 sentry_sdk .flush ()
10191026
@@ -1047,10 +1054,11 @@ def test_request_source_if_duration_over_threshold_span_streaming(
10471054
10481055 url = "http://example.com/"
10491056
1050- if asyncio .iscoroutinefunction (httpx2_client .get ):
1051- asyncio .run (httpx2_client .get (url ))
1052- else :
1053- httpx2_client .get (url )
1057+ with sentry_sdk .traces .start_span (name = "test" ):
1058+ if asyncio .iscoroutinefunction (httpx2_client .get ):
1059+ asyncio .run (httpx2_client .get (url ))
1060+ else :
1061+ httpx2_client .get (url )
10541062
10551063 sentry_sdk .flush ()
10561064
@@ -1099,10 +1107,11 @@ def test_span_origin_span_streaming(
10991107
11001108 url = "http://example.com/"
11011109
1102- if asyncio .iscoroutinefunction (httpx2_client .get ):
1103- asyncio .run (httpx2_client .get (url ))
1104- else :
1105- httpx2_client .get (url )
1110+ with sentry_sdk .traces .start_span (name = "test" ):
1111+ if asyncio .iscoroutinefunction (httpx2_client .get ):
1112+ asyncio .run (httpx2_client .get (url ))
1113+ else :
1114+ httpx2_client .get (url )
11061115
11071116 sentry_sdk .flush ()
11081117
@@ -1131,10 +1140,11 @@ def test_http_url_attributes_span_streaming(
11311140
11321141 url = "http://example.com/?foo=bar#frag"
11331142
1134- if asyncio .iscoroutinefunction (httpx2_client .get ):
1135- asyncio .run (httpx2_client .get (url ))
1136- else :
1137- httpx2_client .get (url )
1143+ with sentry_sdk .traces .start_span (name = "test" ):
1144+ if asyncio .iscoroutinefunction (httpx2_client .get ):
1145+ asyncio .run (httpx2_client .get (url ))
1146+ else :
1147+ httpx2_client .get (url )
11381148
11391149 sentry_sdk .flush ()
11401150
@@ -1167,10 +1177,11 @@ def test_http_url_attributes_no_query_or_fragment_span_streaming(
11671177
11681178 url = "http://example.com/"
11691179
1170- if asyncio .iscoroutinefunction (httpx2_client .get ):
1171- asyncio .run (httpx2_client .get (url ))
1172- else :
1173- httpx2_client .get (url )
1180+ with sentry_sdk .traces .start_span (name = "test" ):
1181+ if asyncio .iscoroutinefunction (httpx2_client .get ):
1182+ asyncio .run (httpx2_client .get (url ))
1183+ else :
1184+ httpx2_client .get (url )
11741185
11751186 sentry_sdk .flush ()
11761187
@@ -1202,10 +1213,11 @@ def test_http_url_attributes_pii_disabled_span_streaming(
12021213
12031214 url = "http://example.com/?foo=bar#frag"
12041215
1205- if asyncio .iscoroutinefunction (httpx2_client .get ):
1206- asyncio .run (httpx2_client .get (url ))
1207- else :
1208- httpx2_client .get (url )
1216+ with sentry_sdk .traces .start_span (name = "test" ):
1217+ if asyncio .iscoroutinefunction (httpx2_client .get ):
1218+ asyncio .run (httpx2_client .get (url ))
1219+ else :
1220+ httpx2_client .get (url )
12091221
12101222 sentry_sdk .flush ()
12111223
0 commit comments