Sentry-java: Add configuration to easily exclude events based on exception

Created on 4 Apr 2018  路  5Comments  路  Source: getsentry/sentry-java

https://twitter.com/inodb/status/981292517898571776

        Sentry.getStoredClient().addShouldSendEventCallback(new ShouldSendEventCallback() {
            public boolean shouldSend(Event event) {
                for (Map.Entry<String, SentryInterface> interfaceEntry : event.getSentryInterfaces().entrySet()) {
                    if (interfaceEntry.getValue() instanceof ExceptionInterface) {
                        ExceptionInterface i = (ExceptionInterface) interfaceEntry.getValue();
                        for (SentryException sentryException : i.getExceptions()) {
                            if (sentryException.getExceptionClassName().equals("foo") {
                                return false;
                            }
                        }
                    }
                }

                return true;
            }
        });
enhancement

Most helpful comment

This could be built-in. So during Sentry.init one passes the types of Exceptions to ignore.

All 5 comments

I will upvote on this: something similar like the ignore_exceptions parameter in raven-python, and can be configured both in code and via sentry.properties will be great.

@bretthoerner @miketeo how do you guys solve this issue? i can't find any examples regarding this yet.

Thanks @bretthoerner for the code snippet !
We used it to make it configurable through an environment variable : https://github.com/voyages-sncf-technologies/hesperides/pull/691/files#diff-d729437ba7e0f7f1c29b2abda2d35318

This could be built-in. So during Sentry.init one passes the types of Exceptions to ignore.

This issue is a duplicate of https://github.com/getsentry/sentry-java/issues/761 but considering how frequently this feature is requested I am leaning towards adding this as a configuration option like @bruno-garcia suggested.

Was this page helpful?
0 / 5 - 0 ratings