@@ -739,15 +739,22 @@ def test_if_headers_equals_none(self):
739739 self .assert_span ()
740740
741741 def test_ignores_excluded_urls (self ):
742- with mock .patch .dict (
743- "os.environ" , {"OTEL_PYTHON_HTTPX_EXCLUDED_URLS" : self .URL }
742+ for env_var in (
743+ "OTEL_PYTHON_HTTPX_EXCLUDED_URLS" ,
744+ "OTEL_PYTHON_EXCLUDED_URLS" ,
744745 ):
745- client = self .create_client ()
746- HTTPXClientInstrumentor ().instrument_client (client = client )
747- self .perform_request (self .URL , client = client )
748- self .assert_span (num_spans = 0 )
749- self .assert_metrics (num_metrics = 0 )
750- HTTPXClientInstrumentor ().uninstrument_client (client )
746+ with self .subTest (env_var = env_var ):
747+ with mock .patch .dict (
748+ "os.environ" , {env_var : self .URL }, clear = True
749+ ):
750+ client = self .create_client ()
751+ HTTPXClientInstrumentor ().instrument_client (
752+ client = client
753+ )
754+ self .perform_request (self .URL , client = client )
755+ self .assert_span (num_spans = 0 )
756+ self .assert_metrics (num_metrics = 0 )
757+ HTTPXClientInstrumentor ().uninstrument_client (client )
751758
752759 class BaseManualTest (BaseTest , metaclass = abc .ABCMeta ):
753760 @abc .abstractmethod
@@ -984,15 +991,24 @@ def test_client_mounts_with_instrumented_transport(self):
984991 self .assertEqual (spans [1 ].attributes [HTTP_URL ], https_url )
985992
986993 def test_ignores_excluded_urls (self ):
987- with mock .patch .dict (
988- "os.environ" , {"OTEL_PYTHON_HTTPX_EXCLUDED_URLS" : self .URL }
994+ for env_var in (
995+ "OTEL_PYTHON_HTTPX_EXCLUDED_URLS" ,
996+ "OTEL_PYTHON_EXCLUDED_URLS" ,
989997 ):
990- client = self .create_client ()
991- HTTPXClientInstrumentor ().instrument_client (client = client )
992- self .perform_request (self .URL , client = client )
993- self .assert_span (num_spans = 0 )
994- self .assert_metrics (num_metrics = 0 )
995- HTTPXClientInstrumentor ().uninstrument_client (client = client )
998+ with self .subTest (env_var = env_var ):
999+ with mock .patch .dict (
1000+ "os.environ" , {env_var : self .URL }, clear = True
1001+ ):
1002+ client = self .create_client ()
1003+ HTTPXClientInstrumentor ().instrument_client (
1004+ client = client
1005+ )
1006+ self .perform_request (self .URL , client = client )
1007+ self .assert_span (num_spans = 0 )
1008+ self .assert_metrics (num_metrics = 0 )
1009+ HTTPXClientInstrumentor ().uninstrument_client (
1010+ client = client
1011+ )
9961012
9971013 @mock .patch .dict ("os.environ" , {"NO_PROXY" : "" }, clear = True )
9981014 class BaseInstrumentorTest (BaseTest , metaclass = abc .ABCMeta ):
@@ -1354,15 +1370,22 @@ def test_uninstrument_client_with_proxy(self):
13541370 self .assert_span ()
13551371
13561372 def test_ignores_excluded_urls (self ):
1357- # need to instrument again for the environment variable
1358- HTTPXClientInstrumentor ().uninstrument_client (self .client )
1359- with mock .patch .dict (
1360- "os.environ" , {"OTEL_PYTHON_HTTPX_EXCLUDED_URLS" : self .URL }
1373+ for env_var in (
1374+ "OTEL_PYTHON_HTTPX_EXCLUDED_URLS" ,
1375+ "OTEL_PYTHON_EXCLUDED_URLS" ,
13611376 ):
1362- HTTPXClientInstrumentor ().instrument_client (client = self .client )
1363- self .perform_request (self .URL , client = self .client )
1364- self .assert_span (num_spans = 0 )
1365- self .assert_metrics (num_metrics = 0 )
1377+ with self .subTest (env_var = env_var ):
1378+ client = self .create_client ()
1379+ with mock .patch .dict (
1380+ "os.environ" , {env_var : self .URL }, clear = True
1381+ ):
1382+ HTTPXClientInstrumentor ().instrument_client (
1383+ client = client
1384+ )
1385+ self .perform_request (self .URL , client = client )
1386+ self .assert_span (num_spans = 0 )
1387+ self .assert_metrics (num_metrics = 0 )
1388+ HTTPXClientInstrumentor ().uninstrument_client (client )
13661389
13671390
13681391class TestSyncIntegration (BaseTestCases .BaseManualTest ):
0 commit comments