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

Question: Usage of add_filter #195

Closed
janklimo opened this issue Apr 24, 2017 · 3 comments
Closed

Question: Usage of add_filter #195

janklimo opened this issue Apr 24, 2017 · 3 comments
Labels

Comments

@janklimo
Copy link

We have the following snippet in our initializer:

Airbrake.add_filter do |notice|
  if notice[:context] && notice[:context][:userAgent]
    notice.ignore! if notice[:context][:userAgent].match(/BLEXBot/)
  end
end

However, errors originating from BLEXBot keep appearing in Airbrake. Can you see any problem in the way we use it? Many thanks.

@kyrylo
Copy link
Contributor

kyrylo commented Apr 24, 2017

There's no need to check for notice[:context] because it's always present. So far I cannot see anything wrong in your snippet. Could you contact our support and link to the error which has this user agent?

@janklimo
Copy link
Author

Will do, thank you.

@kyrylo
Copy link
Contributor

kyrylo commented Apr 25, 2017

Thanks! So what happens is that notice[:context][:userAgent] is always nil in that filter.

tmux 2017-04-25 14-51-12

I am going to reopen this issue because I consider this to be a bug. Library filters should be added before all user filters, which is not happening as of now.

To workaround the issue, you could craft the following filter:

Airbrake.add_filter do |notice|
  if notice.stash[:rack_request]
    notice.ignore! if notice.stash[:rack_request].user_agent.match(/BLEXBot/)
  end
end

@kyrylo kyrylo reopened this Apr 25, 2017
@kyrylo kyrylo added Bug and removed Question labels Apr 25, 2017
kyrylo added a commit that referenced this issue Apr 25, 2017
Fixes #195 (Question: Usage of add_filter)

We need to make sure that Airbrake library have higher precedence over
user filters to avoid confusion when expected data is not present in
the Notice object.
kyrylo added a commit that referenced this issue Apr 26, 2017
Fixes #195 (Question: Usage of add_filter)

We need to make sure that Airbrake library have higher precedence over
user filters to avoid confusion when expected data is not present in
the Notice object.
kyrylo added a commit that referenced this issue Apr 26, 2017
kyrylo added a commit that referenced this issue Apr 26, 2017
kyrylo added a commit that referenced this issue Apr 26, 2017
Fixes #195 (Question: Usage of add_filter)

We need to make sure that Airbrake library have higher precedence over
user filters to avoid confusion when expected data is not present in
the Notice object.
kyrylo added a commit that referenced this issue Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants