Hi there,
I work on a Kotlin application (with Spring boot) and want to ignore some Exception/Sentry events from Error logging for all exceptions that come from some particular libraries. What I have tried to do so far is to override the class SentryOptions.BeforeSendCallback
but it doesn’t seem to work.
See code:
class SentryBeforeSendCallback : SentryOptions.BeforeSendCallback {
override fun execute(event: SentryEvent, hint: Any?): SentryEvent? {
// Any exceptions from the following list of loggers will be ignored in Sentry (a.k.a. no Sentry issue will be created)
val loggersToIgnore = hashSetOf("com.microsoft.azure.sdk")
if ((event.throwable != null && loggersToIgnore.any { event.throwable!!.toString().contains(it) }) ||
(event.logger != null && loggersToIgnore.any { event.logger!!.toString().contains(it) })
) {
return null
}
return event
}
Locally I can successfully ignore exceptions (manually and via tests) but in production it doesn’t seem to work.
I came upon this PR in the JavaScript version of sentry and they say that BeforeSendCallback is disabled, but I couldn’t reproduce the suggested code in Kotlin.
Another attempt at it was to create a class TracesSamplerCallback
but this class doesn’t seem to be triggered at all.
A follow up question is then- is it possible to ignore exception that are triggered via log Error but NOT ignore them if they are unhandled?
Thanks