Exclude the HTTP server response events from Sentry

This commit is contained in:
Quentin Gliech
2025-04-17 13:19:46 +02:00
parent 37a0af85a6
commit c380cd0f98

View File

@@ -128,9 +128,11 @@ async fn try_main() -> anyhow::Result<ExitCode> {
let sentry_layer = sentry.is_enabled().then(|| {
sentry_tracing::layer().event_filter(|md| {
// All the spans in the handlers module send their data to Sentry themselves, so
// we only create breadcrumbs for them, instead of full events
if md.target().starts_with("mas_handlers::") {
// By default, Sentry records all events as breadcrumbs, except errors.
//
// Because we're emitting error events for 5xx responses, we need to exclude
// them and also record them as breadcrumbs.
if md.name() == "http.server.response" {
EventFilter::Breadcrumb
} else {
sentry_tracing::default_event_filter(md)