Fix RequestsInstrumentor for custom transport adapters#562
Fix RequestsInstrumentor for custom transport adapters#562codeboten merged 6 commits intoopen-telemetry:mainfrom
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.
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.
These changes don't seem directly related to the description of this change, were these attributes superfluous?
There was a problem hiding this comment.
I think this is the dead code @mariojonke is talking about in the PR description.
There was a problem hiding this comment.
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: