-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix RequestsInstrumentor for custom transport adapters #562
Fix RequestsInstrumentor for custom transport adapters #562
Conversation
remove dead/leftover code from an early metrics implementation which tried to access the raw.version attribute on the response object. The 'version' attribute might not be present in every case, especially when custom transport adapters are used.
instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good, I just have one question before approving.
@@ -131,10 +131,6 @@ def _instrumented_requests_call( | |||
|
|||
url = remove_url_credentials(url) | |||
|
|||
labels = {} | |||
labels[SpanAttributes.HTTP_METHOD] = method | |||
labels[SpanAttributes.HTTP_URL] = url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes don't seem directly related to the description of this change, were these attributes superfluous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the dead code @mariojonke is talking about in the PR description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the labels
are a leftover from the old metrics implementation. Since all the metrics related code got removed, the labels are unused.
Do client semantic conventions allow http.falvor? I think we could do something like |
Semantic conventiosn for
Also, I think the removed code for parsing the version appears to be incorrect. In the HTTPResponse docs the version is defined as |
@lonewolf3739 please approve if your comments have been addressed, thanks! |
The
RequestsInstrumentor
contained some dead code from an early metrics implementation that in certain situations failed with anAttributeError
. TheAttributeError
happened when trying to determine the HTTP flavor from theraw.version
attribute on the returnedResponse
object.By default, the
raw
attribute is anurllib3
response that has theversion
attribute. However,requests
allows mounting custom transport adapters for certain URLs.A custom adapter can return a
Response
where theraw
object isn't anurllib3
response and the version attribute might not be present. Thus, theRequestsInstrumentor
could run into anAttributeError
.This change removes the dead metrics code.
Type of change
How Has This Been Tested?
Additional unit test to verify that the
RequestsInstrumentor
works with custom transport adapters.Does This PR Require a Core Repo Change?
Checklist: