Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Dec 13, 2024
1 parent f209059 commit ed97732
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,9 @@ def instrument_client(
that is called right before the span ends
"""

if getattr(client, "_is_instrumented_by_opentelemetry", False):
if getattr(
client._transport, "_is_instrumented_by_opentelemetry", False
):
_logger.warning(
"Attempting to instrument Httpx client while already instrumented"
)
Expand Down Expand Up @@ -946,7 +948,7 @@ def instrument_client(
response_hook=response_hook,
),
)
client._is_instrumented_by_opentelemetry = True
client._transport._is_instrumented_by_opentelemetry = True
if hasattr(client._transport, "handle_async_request"):
wrap_function_wrapper(
client._transport,
Expand All @@ -972,7 +974,7 @@ def instrument_client(
async_response_hook=async_response_hook,
),
)
client._is_instrumented_by_opentelemetry = True
client._transport._is_instrumented_by_opentelemetry = True

@staticmethod
def uninstrument_client(
Expand All @@ -987,9 +989,9 @@ def uninstrument_client(
unwrap(client._transport, "handle_request")
for transport in client._mounts.values():
unwrap(transport, "handle_request")
client._is_instrumented_by_opentelemetry = False
client._transport._is_instrumented_by_opentelemetry = False
elif hasattr(client._transport, "handle_async_request"):
unwrap(client._transport, "handle_async_request")
for transport in client._mounts.values():
unwrap(transport, "handle_async_request")
client._is_instrumented_by_opentelemetry = False
client._transport._is_instrumented_by_opentelemetry = False

0 comments on commit ed97732

Please sign in to comment.