-
Notifications
You must be signed in to change notification settings - Fork 152
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!: remove enable_recognize_route and span_naming options #214
fix!: remove enable_recognize_route and span_naming options #214
Conversation
e3deb6e
to
9da5dba
Compare
CI failure is relevant.
|
Ah, I only ran the |
`recognize_route` can end up mutating the request object in the event it processes a potential match that is not anchored. That is, shall we say, not ideal. (And causes production applications to break). I was initially going to just default the options to `off` (essentially), but why leave potentially dangerous code lying about? Also, it ended up being easier to just yank stuff out rather than fix the test cases to handle the inverse of what the expected, etc. So, this commit just removes it all. Step backwards in convenience, sure. Big step forward in safety? Definitely. For context: https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/123/files#r1035711863
9da5dba
to
24652b6
Compare
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
_(span.attributes['http.route']).must_equal '/ok(.:format)' | ||
end | ||
|
||
it 'sets the span name when the controller raises an exception' do |
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 basic scenarios are basically copy/pasta from the above, which is why it's ok to remove.
else "#{request.method} #{rails_route(request)}" | ||
end | ||
end | ||
rack_span.name = "#{self.class.name}##{name}" unless request.env['action_dispatch.exception'] |
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.
In days of yore, it looks like we checked for valid context on the rack span. Not sure if we want to bring that back; not a blocker, just a detail I wanted to surface.
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.
@plantfansam I may be incorrect here but I think that checking if it is read/write span i.e. recording?
, is better than checking for a valid context.
If I understand this code correctly, it is possible to have a read-only span that has a valid context:
I think that means it would call the no-opt name
and add_attributes
methods: https://github.com/open-telemetry/opentelemetry-ruby/blob/a4efaf3a44b0efc6ca805a6d0a5bdc4f13a01b34/api/lib/opentelemetry/trace/span.rb#L138
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 read the code the same way @arielvalentin, and agree with your reasoning!
We leverage |
The only thing I can think of at the moment is to amend the current span in a OpenTelemetry::Trace.current_span.set_attribute("http.route", "#{request.request_method} #{params[:controller]}/#{params[:action]}") |
Hmm… that's better than missing out on the attribute entirely. But it's not the same fidelity as we were getting from Well, either way, this probably belongs as a discussion in a new Issue or Discussion. Thanks for the great work, y'all! |
It looks like Rails 7 will be adding a safer way to get the route URI pattern: rails/rails#47129 |
recognize_route
can end up mutating the request object in the event itprocesses a potential match that is not anchored. That is, shall we say,
not ideal. (And causes production applications to break).
I was initially going to just default the options to
off
(essentially), but why leave potentially dangerous code lying about?
Also, it ended up being easier to just yank stuff out rather than fix
the test cases to handle the inverse of what the expected, etc. So, this
commit just removes it all.
Step backwards in convenience, sure. Big step forward in safety? Definitely.
For context: https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/123/files#r1035711863