Skip to content

Commit de4aef3

Browse files
Rafal-Chrzanowski-IBMGSVarsha
authored andcommitted
refactor: Removed unnecessary try-except
Signed-off-by: Rafal Chrzanowski <Rafal.Chrzanowski@ibm.com>
1 parent 5412007 commit de4aef3

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/instana/instrumentation/httpx.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,20 @@ def handle_request_with_instana(
8282
) as span:
8383
try:
8484
request = args[0]
85-
_set_request_span_attributes(span, request)
85+
_set_request_span_attributes(span, request) # Has its own try-except
8686
tracer.inject(span.context, Format.HTTP_HEADERS, request.headers)
8787
except Exception:
88-
logger.exception("httpx handle_request_with_instana pre-request:")
88+
logger.exception(
89+
"httpx handle_request_with_instana pre-request:", exc_info=True
90+
)
8991

9092
try:
9193
response = wrapped(*args, **kwargs)
9294
except Exception as e:
9395
span.record_exception(e)
9496
raise
9597

96-
try:
97-
_set_response_span_attributes(span, response)
98-
except Exception:
99-
logger.exception("httpx handle_request_with_instana post-request:")
98+
_set_response_span_attributes(span, response) # Has its own try-except
10099

101100
return response
102101

@@ -119,21 +118,21 @@ async def handle_async_request_with_instana(
119118
) as span:
120119
try:
121120
request = args[0]
122-
_set_request_span_attributes(span, request)
121+
_set_request_span_attributes(span, request) # Has its own try-except
123122
tracer.inject(span.context, Format.HTTP_HEADERS, request.headers)
124123
except Exception:
125-
logger.exception("httpx handle_request_with_instana pre-request:")
124+
logger.exception(
125+
"httpx handle_async_request_with_instana pre-request:",
126+
exc_info=True,
127+
)
126128

127129
try:
128130
response = await wrapped(*args, **kwargs)
129131
except Exception as e:
130132
span.record_exception(e)
131133
raise
132134

133-
try:
134-
_set_response_span_attributes(span, response)
135-
except Exception:
136-
logger.exception("httpx handle_request_with_instana post-request:")
135+
_set_response_span_attributes(span, response) # Has its own try-except
137136

138137
return response
139138

0 commit comments

Comments
 (0)