fix: Added exception re-raise in httpx method overwrites#867
fix: Added exception re-raise in httpx method overwrites#867Rafal-Chrzanowski-IBM wants to merge 3 commits intoinstana:mainfrom
Conversation
|
❌ @Rafal-Chrzanowski-IBM the
📝 What should I do to fix it?All proposed commits should include a sign-off in their messages, ideally at the end. ❔ Why it is requiredThe Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project. Here is the full text of the DCO, reformatted for readability:
Contributors sign-off that they adhere to these requirements by adding a Git even has a |
Signed-off-by: Rafal Chrzanowski <Rafal.Chrzanowski@ibm.com>
a6dd88d to
4e3dc77
Compare
There was a problem hiding this comment.
Hi @Rafal-Chrzanowski-IBM, thanks for the PR!
According to our spec, we aren't supposed to raise exceptions that are caused by our instrumentation code. But I understand that we shouldn't suppress the exceptions coming from the underlying client library as well. Could you please re-raise the exception only for the original wrapped call as in the snippet I've shared below?
Please update the code (for both the methods) and verify from your end if it fixes the issue. We can then review the PR again, thanks!
try:
request = args[0]
_set_request_span_attributes(span, request) # Has its own try-except
tracer.inject(span.context, Format.HTTP_HEADERS, request.headers)
except Exception:
logger.debug("httpx handle_request_with_instana:", exc_info=True)
try:
response = wrapped(*args, **kwargs)
except Exception as e:
span.record_exception(e)
raise
_set_response_span_attributes(span, response) # Has its own try-exceptThere was a problem hiding this comment.
Hi @GSVarsha, thank you for taking a look so quickly. I updated the code according to your suggestions. Please let me know whether I should make any further changes to the PR. Thank you.
Signed-off-by: Rafal Chrzanowski <Rafal.Chrzanowski@ibm.com>
Signed-off-by: Rafal Chrzanowski <Rafal.Chrzanowski@ibm.com>
Fixes #866.
Added exception re-raise after exception has been recorded.
Previously
pylanceshowed the following warning:Currently this warning isn't visible anymore.