getsentry / sentry-dotnet

Sentry SDK for .NET
https://docs.sentry.io/platforms/dotnet
MIT License
591 stars 207 forks source link

Offline caching improvements - Delay between and backoff when 429 is on #1504

Open bruno-garcia opened 2 years ago

bruno-garcia commented 2 years ago

The SDK guideline has a couple of new items regarding offline caching: https://github.com/getsentry/develop/pull/509

Retry on the background is tracked here: #803 but two main items are new:

  1. If rate-limit was hit, make sure the caching transport is aware. Meaning: don't read all files from disk to send to the HTTP transport when that's basically dropping everything due to rate-limit
  2. Add a delay when reading from disk to avoid bursts of events which could trigger rate limit
bruno-garcia commented 2 years ago

https://develop.sentry.dev/sdk/features/#additional-capabilities

bitsandfoxes commented 3 months ago

The CachingTransport is currently unaware of any ratelimiting. This exclusively happens in the inner transport https://github.com/getsentry/sentry-dotnet/blob/a029918cfb184c0219b4658b5f082ff91e129f79/src/Sentry/Http/HttpTransportBase.cs#L98-L99

A couple of things:

  1. We'd need to extract the rate limiter from the transport. I.e. sentry-java holds it on the hub.
  2. How would we get around reading the envelopes from disk again when the ratelimiting is tied to a category?
  3. 429 means no category specified. So we actually don't need to read anything and just back off!