-
Notifications
You must be signed in to change notification settings - Fork 277
[Excon] Fix error with upper-case HTTP methods #1147
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
[Excon] Fix error with upper-case HTTP methods #1147
Conversation
ericmustin
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.
👍
Thanks for the contribution. Indeed, reviewing the docs. Excon appears to accept either a string or a symbol as it's :method option input, so this is a more robust approach imo, I suppose there's some very very minor performance tradeoff from calling .to_s.upcase instead of just looking up a Hash value, but I think this is probably negligible and I doubt even measurable in a production system.
Minor programming note that the excon instrumentation has been pretty unloved so if you notice any other issues, feel free to push up a PR.
Cheers!
|
👋🏼 This was indeed converted into a constant hash to reduce string allocation: Does duplicating entires in the hash to use both symbols and strings solve this issue? |
|
^ ditto what @arielvalentin said, missed that in initial review sorry about that |
|
We need to support both symbols and strings. I would imagine that using an What do you suggest? |
There's two options here I think. We can setup an adaptive hash like what was done in the net/http instrumentation here. Or we could simply I think it's better that we use the adaptive hash as in the worst case (an app using |
We should in general, avoid pulling in ActiveSupport (or any additional gem) as a dependency of any instrumentation gem in this repo. |
|
If we want to avoid all memory allocation, we'll want an adaptive hash for the HTTP method and another for the span name... |
+1 |
|
I added adaptive hashes for the HTTP method and the span name. |
When Excon was called with an HTTP method in upper-case, the instrumentation failed to capture the 'http.method' and set it to `nil`. This caused the response instrumentation to log the following error: ``` OpenTelemetry error: invalid span attribute value type NilClass for key 'http.method' on span 'HTTP ' ``` This commit fixes the issue and captures the 'http.method' regardless of its casing.
a3a6efa to
95af227
Compare
instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb
Outdated
Show resolved
Hide resolved
instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb
Outdated
Show resolved
Hide resolved
95af227 to
354ba78
Compare
mwear
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.
LGTM
instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb
Show resolved
Hide resolved
|
Hi, @arielvalentin, @mwear and @plantfansam. This PR has been approved a week ago. Is there anything missing before merging it? |
|
cc: @open-telemetry/ruby-maintainers |
When Excon is called with an HTTP method in upper-case, the instrumentation fails to capture the
'http.method'and sets it tonil. This causes the response instrumentation to log the following error:This PR fixes the issue and captures the
'http.method'regardless of its casing.