@@ -155,6 +155,7 @@ def setUp(self):
155155 self .env_patch = mock .patch .dict (
156156 "os.environ" ,
157157 {
158+ "OTEL_PYTHON_HTTPX_EXCLUDED_URLS" : "http://localhost/env_excluded_arg/123,env_excluded_noarg" ,
158159 OTEL_SEMCONV_STABILITY_OPT_IN : sem_conv_mode ,
159160 },
160161 )
@@ -749,22 +750,8 @@ def get_transport_handler(self, transport):
749750
750751 def setUp (self ):
751752 super ().setUp ()
752- self .env_patch = mock .patch .dict (
753- "os.environ" ,
754- {
755- "OTEL_PYTHON_HTTPX_EXCLUDED_URLS" : "http://localhost/env_excluded_arg/123,env_excluded_noarg"
756- },
757- )
758- self .env_patch .start ()
759-
760- self .exclude_patch = mock .patch (
761- "opentelemetry.instrumentation.httpx._excluded_urls_from_env" ,
762- get_excluded_urls ("HTTPX" ),
763- )
764- self .exclude_patch .start ()
765753 self .client = self .create_client ()
766754 HTTPXClientInstrumentor ().instrument_client (self .client )
767- self .env_patch .stop ()
768755
769756 def tearDown (self ):
770757 HTTPXClientInstrumentor ().uninstrument ()
@@ -973,31 +960,22 @@ def test_uninstrument(self):
973960
974961 def test_excluded_urls_explicit (self ):
975962 url_404 = "http://mock/status/404"
976- httpretty .register_uri (
977- httpretty .GET ,
978- url_404 ,
979- status = 404 ,
980- )
963+ respx .get (url_404 ).mock (httpx .Response (404 ))
981964
982965 HTTPXClientInstrumentor ().instrument (excluded_urls = ".*/404" )
983966 client = self .create_client ()
984- self .perform_request (self .URL )
985- self .perform_request (url_404 )
967+ self .perform_request (self .URL , client = client )
968+ self .perform_request (url_404 , client = client )
986969
987970 self .assert_span (num_spans = 1 )
988971
989972 def test_excluded_urls_from_env (self ):
990973 url = "http://localhost/env_excluded_arg/123"
991- httpretty .register_uri (
992- httpretty .GET ,
993- url ,
994- status = 200 ,
995- )
996-
974+ respx .get (url = url ).mock (httpx .Response (200 ))
997975 HTTPXClientInstrumentor ().instrument ()
998976 client = self .create_client ()
999- self .perform_request (self .URL )
1000- self .perform_request (url )
977+ self .perform_request (self .URL , client = client )
978+ self .perform_request (url , client = client )
1001979
1002980 self .assert_span (num_spans = 1 )
1003981
0 commit comments