getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.97k stars 1.57k forks source link

Ignore sampleRate #1011

Closed irudoy closed 6 years ago

irudoy commented 7 years ago

When I use methods captureException and captureMessage, I don't have the ability to ignore the sampleRate option. Is it possible to implement this?

kamilogorek commented 7 years ago

Sounds reasonable. There are scenarios where you'd want to send an error to the dashboard, despite having 20% sample rate. It's also pretty straightforward to implement.

Raven.captureMessage('Wubba Lubba Dub Dub', {
  skipSampleRate: true
});

Raven.captureError(new Error('Bird Person'), {
  skipSampleRate: true
});

Thoughts @benvinegar?

benvinegar commented 7 years ago

See, my concern here is that people will call these methods in such a way that they'll blow their quota and be mad the sample rate didn't help them, even if they disabled it using this option. I'm not convinced you should be able to disable it.

Let's keep this issue open for a while to see if other users find this problematic before rushing to a solution.

kamilogorek commented 7 years ago

On the other side, I can definitely see a scenario, where global handlers should be set to let's say 20% sample rate, as one may have a pretty crowded site, but they'd want to make sure that captureException from on their payment component will always reach our servers. Right now there's no way to achieve that.

benvinegar commented 7 years ago

Right now there's no way to achieve that.

I mean, there is (you could implement your own rate limiting in shouldSendCallback), but it's tricky.

FWIW, I can think of a ton of potential scenarios Raven.js doesn't handle well. We wait until there's enough momentum/feedback before implementing them, or Raven.js will not remain manageable nor be capable of staying under 10kb.

MaxBittker commented 7 years ago

my 2c is doing this in shouldSendCallback is a pretty clean solution for now

MillionQW commented 4 years ago

Does this feature come true? I can't find the relevant code for skipSampleRate option in @sentry/javascript.

HazAT commented 4 years ago

Nope it didn't, there is no skipSampleRate. If you want to do a complex filtering logic you need to use beforeSend and return null in case you do not want to send the event. Then you can do your own sample logic.

chornos13 commented 2 years ago

I need this, how can I achieve that now? or is there any workaround using startTransaction/withScope ?

kamilogorek commented 2 years ago

There is no alternative solution to what Daniel already mentioned above:

If you want to do a complex filtering logic you need to use beforeSend and return null in case you do not want to send the event. Then you can do your own sample logic.