Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/instana/instrumentation/httpx.py
Comment thread
GSVarsha marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,22 @@ def handle_request_with_instana(
) as span:
try:
request = args[0]
_set_request_span_attributes(span, request)
_set_request_span_attributes(span, request) # Has its own try-except
tracer.inject(span.context, Format.HTTP_HEADERS, request.headers)
except Exception:
logger.exception(
"httpx handle_request_with_instana pre-request:", exc_info=True
Comment thread
Rafal-Chrzanowski-IBM marked this conversation as resolved.
Outdated
)

try:
response = wrapped(*args, **kwargs)
_set_response_span_attributes(span, response)
except Exception as e:
span.record_exception(e)
else:
return response
raise

_set_response_span_attributes(span, response) # Has its own try-except

return response
Comment thread
Rafal-Chrzanowski-IBM marked this conversation as resolved.

@wrapt.patch_function_wrapper("httpx", "AsyncHTTPTransport.handle_async_request")
async def handle_async_request_with_instana(
Expand All @@ -111,15 +118,23 @@ async def handle_async_request_with_instana(
) as span:
try:
request = args[0]
_set_request_span_attributes(span, request)
_set_request_span_attributes(span, request) # Has its own try-except
tracer.inject(span.context, Format.HTTP_HEADERS, request.headers)
except Exception:
logger.exception(
"httpx handle_async_request_with_instana pre-request:",
Comment thread
Rafal-Chrzanowski-IBM marked this conversation as resolved.
Outdated
exc_info=True,
)

try:
response = await wrapped(*args, **kwargs)
_set_response_span_attributes(span, response)
except Exception as e:
span.record_exception(e)
else:
return response
raise

_set_response_span_attributes(span, response) # Has its own try-except

return response
Comment thread
Rafal-Chrzanowski-IBM marked this conversation as resolved.

logger.debug("Instrumenting httpx")

Expand Down
Loading