getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
38.94k stars 4.18k forks source link

Ignore spans, traces, everything for health checks #78457

Open black-snow opened 2 weeks ago

black-snow commented 2 weeks ago

Environment

SaaS (https://sentry.io/)

What are you trying to accomplish?

I can't quite figure out if there's a way / what's the "canonical" way to filter out everything regarding health checks (or any other action you wan't to be silent). I don't need any APM on my health checks - they can go fully blind.

So far I've seen denyUrls, beforeSend, and server-side filtering, but I'm not sure what exactly they'll filter or if, for example, /health as a denyUrl would even work.

How are you getting stuck?

Not quite sure what to use and to me this seems to be worth a small section in the docs as it should be a rather common case.

Where in the product are you?

Performance

Link

No response

DSN

No response

Version

No response

getsantry[bot] commented 2 weeks ago

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] commented 2 weeks ago

Routing to @getsentry/product-owners-performance for triage ⏲️

dalnoki commented 1 week ago

hey @black-snow thanks for reaching out! In general, I'd recommend enabling the Filter out health check transactions within your project's Inbound Settings. Here you can find information on what we consider to be a health check. Please note that this setting setting will only filter out transactions and not errors. Let me know if you have any additional questions on this!

black-snow commented 1 week ago

@dalnoki thanks for your reply!

I'd rather like to not collect and send stuff on this route in the first place. Sure, I could just sentry.init after the routing happens and do it within each rout but this is clearly not quite ideal*. Isn't there a way to tell the SDK to ignore some routes, URLs, or to kida sentry.stop()? Not sure if it worked to just del sentry in my /health route.

*having a @NoApm on one route sure is less verbose than having @APm on every other route, plus I'd not catch anything before the now rather late init.

dalnoki commented 4 days ago

hi @black-snow, thanks for getting back to me - you could try using a tracesSampler or beforeSendTransaction to filter out these kinds of transactions. Please reference our documentation for additional details: https://docs.sentry.io/platforms/javascript/configuration/filtering/#filtering-transaction-events (I linked the JavaScript docs because I don't know the SDK you're interested in, but this functionality should exist in pretty much every Sentry SDK)

black-snow commented 1 day ago

That's pretty much what my initial search yielded. Filtering will probably work, but it's some I have to do in the code and I also need to (re-) implement the sampling rate then. That's quite cumbersome - I have to go into every project and copypaste that in.

Would be nice to have some config option for this that I can configure from the outside - something like SENTRY_IGNORED_PATHS=/a/b/c,/health and Sentry would then automatically discard everything for these paths.