Skip to content

Review and update Rate Limiting data categories #4535

Closed

Description

@dingsdax

Description

Review the data categories used in the SDK's Rate Limiter and create issues to update them to match the ones documented in our Rate Limiting docs.

This is important because, depending on the implementation, handling this incorrectly can lead to the SDK dropping more important data such as errors.

Activity

  1. added
    .NET
    on Sep 17, 2025
  2. linear commented on Sep 17, 2025

    @linear
  3. jamescrosswell commented on Sep 17, 2025

    @jamescrosswell
    Collaborator

    @dingsdax can we get a bit more detail on this? What needs reviewing/updating?

  4. dingsdax commented on Sep 18, 2025

    @dingsdax
    ContributorAuthor

    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.

  5. jamescrosswell commented on Sep 18, 2025

    @jamescrosswell
    Collaborator

    @Flash0ver I'm assuming you know what needs doing here... it's not too clear to me.

  6. Flash0ver commented on Sep 18, 2025

    @Flash0ver
    Contributor

    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
  7. jamescrosswell commented on Jul 20, 2026

    @jamescrosswell
    Collaborator

    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:

    Envelope item type Category Relay sends Matches compares Result
    event error "error" == "event" ❌ no match
    check_in monitor "monitor" == "check_in" ❌ no match
    log log_item "log_item" == "log" ❌ no match
    statsd metric_bucket special-cased ✅
    trace_metric trace_metric equal ✅
    transaction / span / session / attachment / profile same equal ✅

    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

    1. Bug (high): rate-limit matcher ignores error / monitor / log_item limits — match on DataCategory, fix the test.
    2. Bug (medium): client reports mislabel check_in / log / trace_metric / statsd drops as default.
    3. Chore: add missing DataCategory constants + fix stale docs link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

.NET

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions