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

Ignore Exception by type #1306

Closed
bruno-garcia opened this issue Mar 4, 2021 · 5 comments · Fixed by #1352
Closed

Ignore Exception by type #1306

bruno-garcia opened this issue Mar 4, 2021 · 5 comments · Fixed by #1352
Labels
enhancement New feature or request
Projects

Comments

@bruno-garcia
Copy link
Member

The SDK needs a first class API to filter out exceptions by their type.

The way to filter out today is through beforeSend such as:

Sentry.init(options -> {
  options.setBeforeSend((event, _hint_) -> {
    return event.getThrowable() instanceof SQLException ? null : event;
  });
});

This is a feature in the .NET SDK documented here for reference.

i.e:
SentrySdk.Init(o => o.AddExceptionFilterForType<OperationCanceledException>());

In hindsight maybe not the best name AddExceptionFilterForType, perhaps FilterException<TException> would be a better candidate although keeping the name consistent is also a nice to have.

This issue was originally raised here: #575

@marandaneto
Copy link
Contributor

I've removed the tags cus we use them to filter issues specifically for that platform, if there's no Android or Java tag, then its for both

@bruno-garcia
Copy link
Member Author

OK I won't add the tags in such case going forward. One benefit of adding is that you can search "all Android issues" by clicking the tag but I don't think I've ever done that :)

@maciejwalkowiak maciejwalkowiak moved this from To do to In progress in kanban Mar 18, 2021
@maciejwalkowiak
Copy link
Contributor

Both AddExceptionFilterForType and FilterException don't make it clear if its filter in or filter out. What about SentryOptions#ignoredExceptions with setter and getter (as required for Spring Boot @ConfigurationProperties) and a method SentryOptions#ignoreException(Throwable) for manual configuration?

@bruno-garcia
Copy link
Member Author

Both AddExceptionFilterForType and FilterException don't make it clear if its filter in or filter out. What about SentryOptions#ignoredExceptions with setter and getter (as required for Spring Boot @ConfigurationProperties) and a method SentryOptions#ignoreException(Throwable) for manual configuration?

The problem with that is that it's open for interpretation what that method will do. Does it ignore that instance? Does it ignore by message? message+type?

For that reason I went with ugly but descriptive ForType.

JS SDK has ignoreErrors which I'm not even sure what part of the error it matches against:
https://docs.sentry.io/platforms/javascript/configuration/filtering/#decluttering-sentry

@marandaneto
Copy link
Contributor

I think @maciejwalkowiak point is about the AddExceptionFilter and not ForType
for me, it'd also make more sense addIgnoreExceptionForType for example

maciejwalkowiak added a commit that referenced this issue Mar 24, 2021
@maciejwalkowiak maciejwalkowiak moved this from In progress to Review in progress in kanban Mar 24, 2021
kanban automation moved this from Review in progress to Done Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

3 participants