You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Review and update Rate Limiting data categories #4535
We’ve done a cross-SDK review of how data categories are handled in rate limiting. The goal was to ensure consistent behavior and bring all SDKs in line with the categories defined in our Rate Limiting docs.
This work improves parity across SDKs: by aligning rate limiter handling, we avoid cases where certain categories (e.g. logs) might be treated inconsistently. Getting this right is important, because incorrect handling could cause SDKs to drop higher-priority data such as errors.
I believe I do ... and I think in our case, we need to
verify that we use all Rate Limit Date Categories that we actually send Envelope Item Types for
and, since Rate Limit Date Categories and Envelope Item Types are similar/equivalent but not identical, we may need to do a bit more "mapping" when matching for including/discarding Envelope Items before the Envelope is sent
Initial audit — the categories don't currently line up
Ran an audit against Relay's authoritative data_category.rs and the rate-limiting docs. There are two separate category code paths and both diverge from the documented names.
1. Rate-limit matcher compares against the item type, not the data category (bug, high)
RateLimitCategory.Matches compares the server's rate-limit category name against the raw envelope item type. But the X-Sentry-Rate-Limits header uses data category names, which differ from item types:
The SDK already knows the right mapping — EnvelopeItem.DataCategory has the comment "Yes, the 'event' item type corresponds to the 'error' data category" — but the matcher doesn't use it. RateLimitCategoryTests also bakes in the wrong expectation ("event" should match) with no case asserting "error" matches an event item, so CI can't catch it.
Consequence: when Sentry rate-limits errors (category error), the SDK doesn't recognize it, keeps sending, gets 429'd, and events are dropped downstream / retried instead of cleanly backed off and recorded. Same for check_in and log.
Fix: have Matches compare against the item's DataCategory rather than the raw type, and fix the misleading test.
2. Client reports mislabel some drops as default (bug, medium)
EnvelopeItem.DataCategory falls through to DataCategory.Default for check_in, log, trace_metric, and statsd. So when those are discarded, client reports attribute the loss to default instead of monitor / log_item / trace_metric / metric_bucket, under-counting real categories in dropped-event telemetry.
3. Missing category constants + stale doc link (chore)
DataCategory.cs defines 10 of the ~17 documented categories. Missing ones the SDK actually emits: monitor, log_item, trace_metric, metric_bucket. (replay, profile_chunk, log_byte, trace_metric_byte may or may not apply depending on what .NET produces — worth confirming per feature.) The doc link at the top of the file is also stale (/sdk/rate-limiting/ → /sdk/expected-features/rate-limiting/).
Suggested breakdown
Bug (high): rate-limit matcher ignores error / monitor / log_item limits — match on DataCategory, fix the test.
Activity
linear commentedon Sep 17, 2025
NET-453 Review and update Rate Limiting data categories
jamescrosswell commentedon Sep 17, 2025
@dingsdax can we get a bit more detail on this? What needs reviewing/updating?
dingsdax commentedon Sep 18, 2025
We’ve done a cross-SDK review of how data categories are handled in rate limiting. The goal was to ensure consistent behavior and bring all SDKs in line with the categories defined in our Rate Limiting docs.
This work improves parity across SDKs: by aligning rate limiter handling, we avoid cases where certain categories (e.g. logs) might be treated inconsistently. Getting this right is important, because incorrect handling could cause SDKs to drop higher-priority data such as errors.
jamescrosswell commentedon Sep 18, 2025
@Flash0ver I'm assuming you know what needs doing here... it's not too clear to me.
Flash0ver commentedon Sep 18, 2025
I believe I do ... and I think in our case, we need to
jamescrosswell commentedon Jul 20, 2026
Initial audit — the categories don't currently line up
Ran an audit against Relay's authoritative
data_category.rsand the rate-limiting docs. There are two separate category code paths and both diverge from the documented names.1. Rate-limit matcher compares against the item type, not the data category (bug, high)
RateLimitCategory.Matchescompares the server's rate-limit category name against the raw envelope itemtype. But theX-Sentry-Rate-Limitsheader uses data category names, which differ from item types:Matchescompareseventerror"error" == "event"check_inmonitor"monitor" == "check_in"loglog_item"log_item" == "log"statsdmetric_buckettrace_metrictrace_metrictransaction/span/session/attachment/profileThe SDK already knows the right mapping —
EnvelopeItem.DataCategoryhas the comment "Yes, the 'event' item type corresponds to the 'error' data category" — but the matcher doesn't use it.RateLimitCategoryTestsalso bakes in the wrong expectation ("event"should match) with no case asserting"error"matches an event item, so CI can't catch it.Consequence: when Sentry rate-limits errors (category
error), the SDK doesn't recognize it, keeps sending, gets 429'd, and events are dropped downstream / retried instead of cleanly backed off and recorded. Same forcheck_inandlog.Fix: have
Matchescompare against the item'sDataCategoryrather than the rawtype, and fix the misleading test.2. Client reports mislabel some drops as
default(bug, medium)EnvelopeItem.DataCategoryfalls through toDataCategory.Defaultforcheck_in,log,trace_metric, andstatsd. So when those are discarded, client reports attribute the loss todefaultinstead ofmonitor/log_item/trace_metric/metric_bucket, under-counting real categories in dropped-event telemetry.3. Missing category constants + stale doc link (chore)
DataCategory.csdefines 10 of the ~17 documented categories. Missing ones the SDK actually emits:monitor,log_item,trace_metric,metric_bucket. (replay,profile_chunk,log_byte,trace_metric_bytemay or may not apply depending on what .NET produces — worth confirming per feature.) The doc link at the top of the file is also stale (/sdk/rate-limiting/→/sdk/expected-features/rate-limiting/).Suggested breakdown
error/monitor/log_itemlimits — match onDataCategory, fix the test.check_in/log/trace_metric/statsddrops asdefault.DataCategoryconstants + fix stale docs link.