@@ -37,7 +37,7 @@ def __init__(self, message: str, method: str, url: str):
3737from ...core .json_schema_helper import DecodedType , EncodingType , SchemaMerge
3838from ...core .mode_utils import handle_record_mode , handle_replay_mode
3939from ...core .tracing import TdSpanAttributes
40- from ...core .tracing .span_utils import CreateSpanOptions , SpanUtils
40+ from ...core .tracing .span_utils import CreateSpanOptions , SpanInfo , SpanUtils
4141from ...core .types import (
4242 PackageType ,
4343 SpanKind ,
@@ -181,21 +181,15 @@ def patched_send(
181181
182182 # Pass through if SDK is disabled
183183 if sdk .mode == TuskDriftMode .DISABLED :
184- return original_send (
185- client_self , request , stream = stream , auth = auth , follow_redirects = follow_redirects
186- )
184+ return original_send (client_self , request , stream = stream , auth = auth , follow_redirects = follow_redirects )
187185
188186 def original_call ():
189- return original_send (
190- client_self , request , stream = stream , auth = auth , follow_redirects = follow_redirects
191- )
187+ return original_send (client_self , request , stream = stream , auth = auth , follow_redirects = follow_redirects )
192188
193189 # REPLAY mode: Use handle_replay_mode for proper background request handling
194190 if sdk .mode == TuskDriftMode .REPLAY :
195191 return handle_replay_mode (
196- replay_mode_handler = lambda : instrumentation_self ._handle_replay_send_sync (
197- sdk , module , request
198- ),
192+ replay_mode_handler = lambda : instrumentation_self ._handle_replay_send_sync (sdk , module , request ),
199193 no_op_request_handler = lambda : instrumentation_self ._get_default_response (module , url_str ),
200194 is_server_request = False ,
201195 )
@@ -204,8 +198,13 @@ def original_call():
204198 return handle_record_mode (
205199 original_function_call = original_call ,
206200 record_mode_handler = lambda is_pre_app_start : instrumentation_self ._handle_record_send_sync (
207- client_self , request , stream , is_pre_app_start , original_send ,
208- auth = auth , follow_redirects = follow_redirects
201+ client_self ,
202+ request ,
203+ stream ,
204+ is_pre_app_start ,
205+ original_send ,
206+ auth = auth ,
207+ follow_redirects = follow_redirects ,
209208 ),
210209 span_kind = OTelSpanKind .CLIENT ,
211210 )
@@ -277,9 +276,7 @@ def _handle_record_send_sync(
277276 with SpanUtils .with_span (span_info ):
278277 # Check drop transforms BEFORE making the request
279278 headers = dict (request .headers )
280- if self ._transform_engine and self ._transform_engine .should_drop_outbound_request (
281- method , url , headers
282- ):
279+ if self ._transform_engine and self ._transform_engine .should_drop_outbound_request (method , url , headers ):
283280 # Request should be dropped - mark span and raise exception
284281 span_info .span .set_attribute (
285282 TdSpanAttributes .OUTPUT_VALUE ,
@@ -357,9 +354,7 @@ async def original_call():
357354 # handle_replay_mode returns coroutine which we await
358355 if sdk .mode == TuskDriftMode .REPLAY :
359356 return await handle_replay_mode (
360- replay_mode_handler = lambda : instrumentation_self ._handle_replay_send_async (
361- sdk , module , request
362- ),
357+ replay_mode_handler = lambda : instrumentation_self ._handle_replay_send_async (sdk , module , request ),
363358 no_op_request_handler = lambda : instrumentation_self ._get_default_response (module , url_str ),
364359 is_server_request = False ,
365360 )
@@ -369,8 +364,13 @@ async def original_call():
369364 return await handle_record_mode (
370365 original_function_call = original_call ,
371366 record_mode_handler = lambda is_pre_app_start : instrumentation_self ._handle_record_send_async (
372- client_self , request , stream , is_pre_app_start , original_send ,
373- auth = auth , follow_redirects = follow_redirects
367+ client_self ,
368+ request ,
369+ stream ,
370+ is_pre_app_start ,
371+ original_send ,
372+ auth = auth ,
373+ follow_redirects = follow_redirects ,
374374 ),
375375 span_kind = OTelSpanKind .CLIENT ,
376376 )
@@ -418,9 +418,7 @@ async def _handle_record_send_async(
418418 with SpanUtils .with_span (span_info ):
419419 # Check drop transforms BEFORE making the request
420420 headers = dict (request .headers )
421- if self ._transform_engine and self ._transform_engine .should_drop_outbound_request (
422- method , url , headers
423- ):
421+ if self ._transform_engine and self ._transform_engine .should_drop_outbound_request (method , url , headers ):
424422 # Request should be dropped - mark span and raise exception
425423 span_info .span .set_attribute (
426424 TdSpanAttributes .OUTPUT_VALUE ,
@@ -538,7 +536,7 @@ def _get_request_body_safely(self, request: Any) -> bytes | None:
538536 """
539537 try :
540538 # Check if content is already available (non-streaming requests)
541- if hasattr (request , ' _content' ) and request ._content is not None :
539+ if hasattr (request , " _content" ) and request ._content is not None :
542540 return request .content
543541
544542 # For streaming/multipart requests, read the content
@@ -578,7 +576,7 @@ def _try_get_mock_from_request_sync(
578576 # Extract query params from URL
579577 # httpx.URL has a .params attribute that returns QueryParams
580578 params = {}
581- if hasattr (request .url , ' params' ):
579+ if hasattr (request .url , " params" ):
582580 params = dict (request .url .params )
583581
584582 # Get body from request - handle streaming/multipart bodies
@@ -701,9 +699,7 @@ def _create_mock_response(self, httpx_module: Any, mock_data: dict[str, Any], me
701699 # Create minimal placeholder Response objects for history
702700 # These represent the intermediate redirect responses
703701 for i in range (history_count ):
704- redirect_request = httpx_module .Request (
705- method .upper (), url if i == 0 else f"redirect_{ i } "
706- )
702+ redirect_request = httpx_module .Request (method .upper (), url if i == 0 else f"redirect_{ i } " )
707703 redirect_response = httpx_module .Response (
708704 status_code = 302 , # Standard redirect status
709705 content = b"" ,
@@ -753,7 +749,7 @@ def _finalize_span_from_request(
753749
754750 # Extract query params from URL
755751 params = {}
756- if hasattr (request .url , ' params' ):
752+ if hasattr (request .url , " params" ):
757753 params = dict (request .url .params )
758754
759755 # Get request body - handle streaming/multipart bodies
0 commit comments