aws-observability / aws-rum-web

Amazon CloudWatch RUM Web Client
Apache License 2.0
114 stars 65 forks source link

sessionSampleRate and error reporting #472

Closed renataogarcia closed 6 months ago

renataogarcia commented 7 months ago

What is your general inquiry?

I'm wondering if sessionSampleRate affects error reporting. Are errors always reported, or only for those sessions that are being sampled?

williazz commented 7 months ago

sessionSampleRate affects all RUM events

williazz commented 7 months ago

If you want, you can go down the rabit hole here https://github.com/aws-observability/aws-rum-web/blob/d778bac18b4502fec6748c7a76f4dc2c74ac8bbb/src/event-cache/EventCache.ts#L100

renataogarcia commented 7 months ago

@williazz Thanks! Would make sense to create two sessions/instances with different sample rates, if I want to log all errors but record performance at a different rate?

adebayor123 commented 7 months ago

Session sample rate is determined by the web client configuration. As a result, it's difficult to create two sessions with different sample rates, because that would require that you deploy two different versions of your application.

That being said, if you want to record all errors but record other data at a different rate, you can experiment initializing two web clients, one with sessionSampleRate = 1 to capture all errors with only the Error plugin initialized, and the other with your custom sample rate and other plugins initialized.

Having two web clients initialized had some unintended consequences in the past (such as adding duplicate X-Ray traces), but it's always better to create a prototype and test it out.

williazz commented 7 months ago

Session sample rate is determined by the web client configuration. As a result, it's difficult to create two sessions with different sample rates, because that would require that you deploy two different versions of your application.

+1

renataogarcia commented 7 months ago

@adebayor123 Sorry, I meant two web clients. Ok, I'll try it out.

Also, as an alternative, would it be viable for me to create a custom or patched plugin that logs performance at different sample rate? or this would interfere with the stats reporting in the RUM dashboard?

williazz commented 6 months ago

Also, as an alternative, would it be viable for me to create a custom or patched plugin that logs performance at different sample rate? or this would interfere with the stats reporting in the RUM dashboard?

No, that would be totally fine to implement. Just make sure to disable that plugin you want to ignore, and then refactor our plugin with a different sample rate.

williazz commented 6 months ago

Closing this issue, but feel free to reopen if you have issues implementing.