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

Use load path to normalize vendored gem filenames #316

Merged

Conversation

eugeneius
Copy link
Contributor

Stack trace filenames are currently normalized based on the project root if they're under it, or the load path otherwise. This works for gems when they're installed globally, since they'll be outside the project root and the load path will be used. If the gems are installed into vendor/ under the project root however, the full relative path will be used - which includes the gem version, e.g:

vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb

This means that if you update a gem, any backtraces that pass through it will change and Sentry will see them as new events. Ideally we would always normalize based on the load path for gems, but use the project root for application code.

Instead of introducing a special case for load paths under vendor/, I've used the in_app attribute to decide whether to ignore the load path.

With this change, there are now three cases:

  • When a path is under the project root and matches APP_DIRS_PATTERN, normalize it based on the project root.
  • When a path is under the project root but doesn't match the pattern, first try to normalize it based on the load path, but fall back to using the project root.
  • When a path is outside the project root, normalize it based on the load path.

Stack trace filenames are currently normalized based on the project root
if they're under it, or the load path otherwise. This works for gems
when they're installed globally, since they'll be outside the project
root and the load path will be used. If the gems are installed into
vendor/ under the project root however, the full relative path will be
used - which includes the gem version, e.g:

vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.9/lib/active_support/callbacks.rb

This means that if you update a gem, any backtraces that pass through it
will change and Sentry will see them as new events. Ideally we would
always normalize based on the load path for gems, but use the project
root for application code.

Instead of introducing a special case for load paths under vendor/, I've
used the in_app attribute to decide whether to ignore the load path.

With this change, there are now three cases:

- When a path is under the project root and matches APP_DIRS_PATTERN,
  normalize it based on the project root.

- When a path is under the project root but doesn't match the pattern,
  first try to normalize it based on the load path, but fall back to
  using the project root.

- When a path is outside the project root, normalize it based on the
  load path.
@nateberkopec
Copy link
Contributor

Awesome. Nice job cleaning up that conditional too!

nateberkopec added a commit that referenced this pull request Apr 13, 2015
Use load path to normalize vendored gem filenames
@nateberkopec nateberkopec merged commit 4bd21a8 into getsentry:master Apr 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants