Closed stephanie-anderson closed 2 months ago
A new parameter called namespaces might be returned for the metric_bucket category. If the returned namespaces contain custom, back off transmitting metrics from the SDK. If the namespace is omitted in the response header, back off transmitting metrics from the SDK.
I had to double-check the code to ensure I got this right. @cleptric, please correct me if I'm wrong. When the SDK receives a rate limits header with the category metric_bucket
and a namespace other than custom e.g. transaction, the SDK must not apply a rate limit for metrics.
If the returned namespaces exclusively contain namespaces other than
custom
, do not back off transmitting metrics from the SDK.
Updated the description.
React Native SDK https://github.com/getsentry/sentry-react-native/releases/tag/5.22.0 includes Rate Limits impl from sentry-cocoa
and sentry-android
.
Description
In order to protect our infrastructure and also customers money, Relay is now able to propagate the limits from processing to PoP Relays and further to our SDKs. We need to make sure that all SDKs can stop sending metrics for some orgs (e.g. above quota, abusing Sentry).
The develop specs for this can be found here: https://develop.sentry.dev/sdk/rate-limiting/
The tracking issue for the Ingest team is: https://github.com/getsentry/team-ingest/issues/303
A quick TL;DR: How to Implement
Add a new data category to the existing rate limiter code, called
metric_bucket
. A new parameter callednamespaces
might be returned for themetric_bucket
category. If the returned namespaces containcustom
, back off transmitting metrics from the SDK. If the returned namespaces exclusively contain namespaces other thancustom
, do not back off transmitting metrics from the SDK. If the namespaces are empty (2700:metric_bucket:organization:quota_exceeded:
) or omitted (2700:metric_bucket:organization:quota_exceeded
) in the response header, back off transmitting metrics from the SDK. While we do not support setting metric namespaces in the SDK yet, Relay could return aX-Sentry-Rate-Limits
header that contains a different metric namespace only, e.g.transaction
. In case your SDK supports client outcomes, report rate limited metrics as themetric_bucket
category.Get inspired by Python SDK PR #1 or PHP PR #1 and PHP PR #2.
Why should we be doing this?
We need to protect our infrastructure and respect communicated rate limits.
Why now?
We didn't plan this for the metrics beta, but metrics is adopted pretty well.
Slack-Channel
discuss-ingest
Stakeholder(s)
Ingest team (esp. Oleksandr & Jan)
Team(s)
Mobile, Web Frontend, Web Backend
Implementation Status