-
Notifications
You must be signed in to change notification settings - Fork 818
Fix RequestsInstrumentor for custom transport adapters #562
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
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
codeboten
left a comment
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.
|
|
||
| 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
RequestsInstrumentorcontained some dead code from an early metrics implementation that in certain situations failed with anAttributeError. TheAttributeErrorhappened when trying to determine the HTTP flavor from theraw.versionattribute on the returnedResponseobject.By default, the
rawattribute is anurllib3response that has theversionattribute. However,requestsallows mounting custom transport adapters for certain URLs.A custom adapter can return a
Responsewhere therawobject isn't anurllib3response and the version attribute might not be present. Thus, theRequestsInstrumentorcould 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
RequestsInstrumentorworks with custom transport adapters.Does This PR Require a Core Repo Change?
Checklist: