Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically enable and disable sentry without stopping process?

I have many long-running processes that are using Sentry.io to report their errors. Starting and stopping these processes is expensive so we're trying to selectively disable Sentry without stopping the application.

It doesn't seem like there's a way to say sentry_sdk.disable() (or similar)

The best I can see is setting the sample_rate=0.0 to effectively "disable" the integration by just not sending messages; we lose the RAM though.

Is there a better way, am I missing something?

like image 768
blakev Avatar asked Mar 09 '26 20:03

blakev


1 Answers

You can try using Sentry's BeforeEvent and return null:

   Sentry.init({
      beforeSend(event) {
        if (shouldSendEvent) return event;
        return null;
      }
    });
like image 86
Hugo Avatar answered Mar 12 '26 08:03

Hugo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!