Skip to content
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

Bad http.url when Rails raises exceptions #351

Merged
merged 1 commit into from
Feb 20, 2018

Conversation

delner
Copy link
Contributor

@delner delner commented Feb 20, 2018

While working on improvements for our exception handling support in Rails, I discovered that our http.url was sometimes being given bad URLs after Rails handled exceptions.

At core of this issue, the Rack tracer needs a source of truth for the http.url value. Looking at the env hash, it has a few possible options which to derive this value:

  • PATH_INFO: Must be present on Rack requests. Starts as relative URL value, e.g. /article/1?foo=bar. It's often overwritten by Rails whenever an exception occurs, to the new path its rendering e.g. /500. At end of the trace, this value isn't very useful.
  • REQUEST_URI: Equal to relative URL value, e.g. /article/1?foo=bar. Appears to be provided depending on the web server, may not always be present (for example, when using IIS instead of WEBrick/Puma.)
  • ORIGINAL_FULLPATH: Rails only. Equal to relative URL value, e.g. /article/1?foo=bar. Unlike PATH_INFO, it doesn't get mutated.

The original logic was previously env['REQUEST_URI'] || env['PATH_INFO']. This logic works under the most common of cases, but provides a /500 value when REQUEST_URI isn't present, and an exception is raised in Rails.

This pull request proposes the new value should simply be the original value of PATH_INFO, before the rest of the Rack stack runs. This should universally address all cases.

@delner delner added bug Involves a bug integrations Involves tracing integrations labels Feb 20, 2018
@delner delner added this to the 0.11.3 milestone Feb 20, 2018
@delner delner self-assigned this Feb 20, 2018
@delner delner merged commit 3641fb6 into master Feb 20, 2018
@palazzem palazzem deleted the bugfix/bad_url_for_rails_exceptions branch February 21, 2018 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants