@@ -1182,6 +1182,21 @@ def perform_request(
1182
1182
def create_proxy_transport (self , url ):
1183
1183
return httpx .HTTPTransport (proxy = httpx .Proxy (url ))
1184
1184
1185
+ def test_can_instrument_subclassed_client (self ):
1186
+ class CustomClient (httpx .Client ):
1187
+ pass
1188
+
1189
+ client = CustomClient ()
1190
+ self .assertFalse (
1191
+ isinstance (client ._transport .handle_request , ObjectProxy )
1192
+ )
1193
+
1194
+ HTTPXClientInstrumentor ().instrument ()
1195
+
1196
+ self .assertTrue (
1197
+ isinstance (client ._transport .handle_request , ObjectProxy )
1198
+ )
1199
+
1185
1200
1186
1201
class TestAsyncInstrumentationIntegration (BaseTestCases .BaseInstrumentorTest ):
1187
1202
response_hook = staticmethod (_async_response_hook )
@@ -1257,3 +1272,18 @@ def test_async_request_hook_does_nothing_if_not_coroutine(self):
1257
1272
self .assertEqual (result .text , "Hello!" )
1258
1273
span = self .assert_span ()
1259
1274
self .assertEqual (span .name , "GET" )
1275
+
1276
+ def test_can_instrument_subclassed_async_client (self ):
1277
+ class CustomAsyncClient (httpx .AsyncClient ):
1278
+ pass
1279
+
1280
+ client = CustomAsyncClient ()
1281
+ self .assertFalse (
1282
+ isinstance (client ._transport .handle_async_request , ObjectProxy )
1283
+ )
1284
+
1285
+ HTTPXClientInstrumentor ().instrument ()
1286
+
1287
+ self .assertTrue (
1288
+ isinstance (client ._transport .handle_async_request , ObjectProxy )
1289
+ )
0 commit comments