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

Add backtrace_path_filter config option #266

Merged
merged 2 commits into from
Apr 12, 2022
Merged

Conversation

jeremycw
Copy link
Contributor

What

Adds a config option called backtrace_path_filter that allows the lines in backtraces to be compared against the filter to see if they should be included in the backtrace

Why

Backtraces are limited to a number of lines (default 30) and are often coming from so deep in library/framework code that you may not even see the originating user code in the backtrace. However, library code is often located in a different path than user code. This can be leveraged to filter the call stack to relevant code.

[
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...',
  # potentially many more lines...
  '/var/www/app/my/model.rb',
  '/var/www/app/my/controller.rb',
  '/usr/local/bundle/rails/...',
  '/usr/local/bundle/rails/...'
]

# With `backtrace_path_filter` set to `/var/www/app/` becomes:

[
  '/var/www/app/my/model.rb',
  '/var/www/app/my/controller.rb'
]

@hmadison
Copy link
Collaborator

Hey @jeremycw,

Since this seems to be a Rails related pull request, would it be possible to make the configuration option take a lambda instead of a string so users could pass closures to ActiveSupport::BacktraceCleaner? I would also ask that we add tests for this behavior. For core functionality we would like to keep our 100% branch coverage.

Thanks,
Hunter

@jeremycw
Copy link
Contributor Author

@hmadison Good suggestion. I confirmed that it also works doing ->(trace) { Rails.backtrace_cleaner.clean(trace) }

@daande
Copy link

daande commented Mar 25, 2022

@hmadison right now we are running off of a fork of this gem as this functionality we find helpful so hopefully we can get it merged in

@hmadison
Copy link
Collaborator

Hey @daande,

If you can reach out to your TAM and have them find me internally I can get the CLA stuff handled through them and get this merged Monday.

Thanks,
Hunter

@daande
Copy link

daande commented Mar 28, 2022

@hmadison we created a support request in instana (https://support.instana.com/hc/en-us/requests/25636) hopefully that is sufficient

@daande
Copy link

daande commented Apr 12, 2022

@hmadison any update on this? See attached ticket above.

@hmadison hmadison merged commit c9309eb into instana:master Apr 12, 2022
@hmadison
Copy link
Collaborator

I've merged the change and will work on getting a new release pushed tomorrow morning.

@daande
Copy link

daande commented Apr 25, 2022

@hmadison can you cut a release with this change please?

@hmadison
Copy link
Collaborator

@daande https://rubygems.org/gems/instana/versions/1.209.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants