@@ -739,10 +739,13 @@ def test_outgoing_trace_headers_span_streaming(
739739
740740 items = capture_items ("span" )
741741
742- if asyncio .iscoroutinefunction (httpx_client .get ):
743- response = asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
744- else :
745- response = httpx_client .get (url )
742+ with sentry_sdk .traces .start_span (name = "test" ):
743+ if asyncio .iscoroutinefunction (httpx_client .get ):
744+ response = asyncio .get_event_loop ().run_until_complete (
745+ httpx_client .get (url )
746+ )
747+ else :
748+ response = httpx_client .get (url )
746749
747750 sentry_sdk .flush ()
748751
@@ -781,12 +784,13 @@ def test_outgoing_trace_headers_append_to_baggage_span_streaming(
781784 items = capture_items ("span" )
782785
783786 with mock .patch ("sentry_sdk.tracing_utils.Random.randrange" , return_value = 500000 ):
784- if asyncio .iscoroutinefunction (httpx_client .get ):
785- response = asyncio .get_event_loop ().run_until_complete (
786- httpx_client .get (url , headers = {"baGGage" : "custom=data" })
787- )
788- else :
789- response = httpx_client .get (url , headers = {"baGGage" : "custom=data" })
787+ with sentry_sdk .traces .start_span (name = "test" ):
788+ if asyncio .iscoroutinefunction (httpx_client .get ):
789+ response = asyncio .get_event_loop ().run_until_complete (
790+ httpx_client .get (url , headers = {"baGGage" : "custom=data" })
791+ )
792+ else :
793+ response = httpx_client .get (url , headers = {"baGGage" : "custom=data" })
790794
791795 sentry_sdk .flush ()
792796
@@ -820,10 +824,11 @@ def test_request_source_disabled_span_streaming(
820824
821825 url = "http://example.com/"
822826
823- if asyncio .iscoroutinefunction (httpx_client .get ):
824- asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
825- else :
826- httpx_client .get (url )
827+ with sentry_sdk .traces .start_span (name = "test" ):
828+ if asyncio .iscoroutinefunction (httpx_client .get ):
829+ asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
830+ else :
831+ httpx_client .get (url )
827832
828833 sentry_sdk .flush ()
829834
@@ -864,10 +869,11 @@ def test_request_source_enabled_span_streaming(
864869
865870 url = "http://example.com/"
866871
867- if asyncio .iscoroutinefunction (httpx_client .get ):
868- asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
869- else :
870- httpx_client .get (url )
872+ with sentry_sdk .traces .start_span (name = "test" ):
873+ if asyncio .iscoroutinefunction (httpx_client .get ):
874+ asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
875+ else :
876+ httpx_client .get (url )
871877
872878 sentry_sdk .flush ()
873879
@@ -900,10 +906,11 @@ def test_request_source_span_streaming(
900906
901907 url = "http://example.com/"
902908
903- if asyncio .iscoroutinefunction (httpx_client .get ):
904- asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
905- else :
906- httpx_client .get (url )
909+ with sentry_sdk .traces .start_span (name = "test" ):
910+ if asyncio .iscoroutinefunction (httpx_client .get ):
911+ asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
912+ else :
913+ httpx_client .get (url )
907914
908915 sentry_sdk .flush ()
909916
@@ -957,16 +964,17 @@ def test_request_source_with_module_in_search_path_span_streaming(
957964
958965 url = "http://example.com/"
959966
960- if asyncio .iscoroutinefunction (httpx_client .get ):
961- from httpx_helpers .helpers import async_get_request_with_client
967+ with sentry_sdk .traces .start_span (name = "test" ):
968+ if asyncio .iscoroutinefunction (httpx_client .get ):
969+ from httpx_helpers .helpers import async_get_request_with_client
962970
963- asyncio .get_event_loop ().run_until_complete (
964- async_get_request_with_client (httpx_client , url )
965- )
966- else :
967- from httpx_helpers .helpers import get_request_with_client
971+ asyncio .get_event_loop ().run_until_complete (
972+ async_get_request_with_client (httpx_client , url )
973+ )
974+ else :
975+ from httpx_helpers .helpers import get_request_with_client
968976
969- get_request_with_client (httpx_client , url )
977+ get_request_with_client (httpx_client , url )
970978
971979 sentry_sdk .flush ()
972980
@@ -1018,10 +1026,11 @@ def test_no_request_source_if_duration_too_short_span_streaming(
10181026
10191027 url = "http://example.com/"
10201028
1021- if asyncio .iscoroutinefunction (httpx_client .get ):
1022- asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1023- else :
1024- httpx_client .get (url )
1029+ with sentry_sdk .traces .start_span (name = "test" ):
1030+ if asyncio .iscoroutinefunction (httpx_client .get ):
1031+ asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1032+ else :
1033+ httpx_client .get (url )
10251034
10261035 sentry_sdk .flush ()
10271036
@@ -1055,10 +1064,11 @@ def test_request_source_if_duration_over_threshold_span_streaming(
10551064
10561065 url = "http://example.com/"
10571066
1058- if asyncio .iscoroutinefunction (httpx_client .get ):
1059- asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1060- else :
1061- httpx_client .get (url )
1067+ with sentry_sdk .traces .start_span (name = "test" ):
1068+ if asyncio .iscoroutinefunction (httpx_client .get ):
1069+ asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1070+ else :
1071+ httpx_client .get (url )
10621072
10631073 sentry_sdk .flush ()
10641074
@@ -1107,10 +1117,11 @@ def test_span_origin_span_streaming(
11071117
11081118 url = "http://example.com/"
11091119
1110- if asyncio .iscoroutinefunction (httpx_client .get ):
1111- asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1112- else :
1113- httpx_client .get (url )
1120+ with sentry_sdk .traces .start_span (name = "test" ):
1121+ if asyncio .iscoroutinefunction (httpx_client .get ):
1122+ asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1123+ else :
1124+ httpx_client .get (url )
11141125
11151126 sentry_sdk .flush ()
11161127
@@ -1140,10 +1151,11 @@ def test_http_url_attributes_span_streaming(
11401151
11411152 url = "http://example.com/?foo=bar#frag"
11421153
1143- if asyncio .iscoroutinefunction (httpx_client .get ):
1144- asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1145- else :
1146- httpx_client .get (url )
1154+ with sentry_sdk .traces .start_span (name = "test" ):
1155+ if asyncio .iscoroutinefunction (httpx_client .get ):
1156+ asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1157+ else :
1158+ httpx_client .get (url )
11471159
11481160 sentry_sdk .flush ()
11491161
@@ -1183,10 +1195,11 @@ def test_http_url_attributes_no_query_or_fragment_span_streaming(
11831195
11841196 url = "http://example.com/"
11851197
1186- if asyncio .iscoroutinefunction (httpx_client .get ):
1187- asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1188- else :
1189- httpx_client .get (url )
1198+ with sentry_sdk .traces .start_span (name = "test" ):
1199+ if asyncio .iscoroutinefunction (httpx_client .get ):
1200+ asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
1201+ else :
1202+ httpx_client .get (url )
11901203
11911204 sentry_sdk .flush ()
11921205
0 commit comments