Skip to content

fix(rate-limiting): Honor span and feedback rate limits#3809

Merged
buenaflor merged 2 commits into
mainfrom
buenaflor/fix/rate-limit-categories
Jul 2, 2026
Merged

fix(rate-limiting): Honor span and feedback rate limits#3809
buenaflor merged 2 commits into
mainfrom
buenaflor/fix/rate-limit-categories

Conversation

@buenaflor

@buenaflor buenaflor commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

The X-Sentry-Rate-Limits header parser did not recognize the span and feedback categories. A rate limit for either was parsed as unknown and discarded by the parser, so the SDK kept sending standalone spans and user feedback while the server had rate limited those categories — risking more important data being dropped downstream once the backoff escalated.

The fix maps both header strings to their existing DataCategory values. DataCategory.span / DataCategory.feedback and the client-report serialization already handled these categories; only RateLimitParser._fromStringValue was missing the cases, so the three category lists had drifted apart.

Regression coverage added in rate_limit_parser_test.dart for both categories (mirroring the existing trace_metric / log_byte cases).

Closes #3787

The X-Sentry-Rate-Limits header parser did not recognize the `span`
and `feedback` categories, so a rate limit for either was parsed as
unknown and dropped. The SDK kept sending standalone spans and user
feedback while those categories were rate limited.

Map both header strings to their existing DataCategory values. The enum
and client report serialization already handled them; only the parser
was missing the cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features

Dart

  • Add array attributes to telemetry by buenaflor in #3778
  • Mark span streaming API as non-experimental by buenaflor in #3756

Fixes

  • (rate-limiting) Honor span and feedback rate limits by buenaflor in #3809

Enhancements

  • (flutter) Support int64 values from sentry-native by buenaflor in #3760

Dependencies

Deps

  • chore(deps): update Android SDK to v8.45.0 by github-actions in #3790
  • chore(deps): update Native SDK to v0.15.1 by github-actions in #3757

Internal Changes

  • (flutter) Remove flaky frames measurement tests by buenaflor in #3783
  • Add AI Use section to CONTRIBUTING.md by christophaigner in #3803

🤖 This preview updates automatically when you update the PR.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.22%. Comparing base (9441966) to head (e1bd4f5).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3809      +/-   ##
==========================================
+ Coverage   87.12%   87.22%   +0.10%     
==========================================
  Files         336      336              
  Lines       12081    12083       +2     
==========================================
+ Hits        10525    10540      +15     
+ Misses       1556     1543      -13     
Flag Coverage Δ
sentry 87.24% <100.00%> (+<0.01%) ⬆️
sentry_dio 97.73% <ø> (ø)
sentry_drift 93.57% <ø> (ø)
sentry_file 65.29% <ø> (ø)
sentry_firebase_remote_config 100.00% <ø> (ø)
sentry_flutter 91.51% <ø> (+0.36%) ⬆️
sentry_hive 77.48% <ø> (ø)
sentry_isar 74.37% <ø> (ø)
sentry_link 21.50% <ø> (ø)
sentry_logging 97.01% <ø> (ø)
sentry_sqflite 88.81% <ø> (ø)
sentry_supabase 97.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@buenaflor
buenaflor marked this pull request as ready for review June 30, 2026 11:41
@buenaflor
buenaflor requested a review from denrase as a code owner June 30, 2026 11:41
Copilot AI review requested due to automatic review settings June 30, 2026 11:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes rate-limit header parsing in the Sentry Dart SDK so X-Sentry-Rate-Limits entries for span and feedback correctly map to existing DataCategory values (instead of being treated as unknown and ignored), ensuring the SDK honors server-side throttling for these payload types.

Changes:

  • Add span and feedback cases to RateLimitParser’s category string mapping.
  • Add regression tests covering parsing of span and feedback rate-limit categories.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/dart/lib/src/transport/rate_limit_parser.dart Map span and feedback strings to their corresponding DataCategory values during rate-limit header parsing.
packages/dart/test/protocol/rate_limit_parser_test.dart Add tests asserting span and feedback categories are parsed and applied with the expected duration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 358.11 ms 358.43 ms 0.33 ms
Size 14.55 MiB 15.87 MiB 1.31 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
1980dca 354.77 ms 346.96 ms -7.82 ms
f3771ea 379.02 ms 363.91 ms -15.11 ms
d3fb366 391.49 ms 385.85 ms -5.64 ms
bfabaf2 408.04 ms 444.38 ms 36.34 ms
eee3b3b 373.20 ms 372.54 ms -0.65 ms
393f8ec 360.07 ms 362.70 ms 2.64 ms
e90cf93 374.35 ms 368.40 ms -5.95 ms
e04b24b 504.72 ms 516.43 ms 11.71 ms
a5b28db 383.85 ms 387.65 ms 3.80 ms
f42e9fb 360.91 ms 389.85 ms 28.94 ms

App size

Revision Plain With Sentry Diff
1980dca 14.55 MiB 15.87 MiB 1.31 MiB
f3771ea 14.31 MiB 15.49 MiB 1.19 MiB
d3fb366 13.93 MiB 15.06 MiB 1.13 MiB
bfabaf2 13.93 MiB 15.06 MiB 1.13 MiB
eee3b3b 14.55 MiB 15.87 MiB 1.31 MiB
393f8ec 13.93 MiB 15.06 MiB 1.13 MiB
e90cf93 14.31 MiB 15.56 MiB 1.25 MiB
e04b24b 13.93 MiB 15.00 MiB 1.06 MiB
a5b28db 13.93 MiB 15.18 MiB 1.25 MiB
f42e9fb 14.55 MiB 15.87 MiB 1.31 MiB

Previous results on branch: buenaflor/fix/rate-limit-categories

Startup times

Revision Plain With Sentry Diff
3743ad4 357.20 ms 356.17 ms -1.03 ms

App size

Revision Plain With Sentry Diff
3743ad4 14.55 MiB 15.87 MiB 1.31 MiB

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1250.64 ms 1246.33 ms -4.31 ms
Size 5.83 MiB 6.28 MiB 459.63 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
32914d8 1275.47 ms 1285.20 ms 9.73 ms
eee3b3b 1257.20 ms 1255.59 ms -1.62 ms
793f4dc 1262.50 ms 1282.35 ms 19.85 ms
667e3c4 1254.70 ms 1268.23 ms 13.52 ms
f579250 1248.14 ms 1250.15 ms 2.01 ms
2d65d04 1254.41 ms 1269.24 ms 14.84 ms
e0c8591 1259.85 ms 1257.31 ms -2.54 ms
93b7728 1247.23 ms 1264.87 ms 17.64 ms
640ad0c 1241.04 ms 1253.96 ms 12.92 ms
d052aef 1246.33 ms 1253.04 ms 6.71 ms

App size

Revision Plain With Sentry Diff
32914d8 7.86 MiB 9.44 MiB 1.58 MiB
eee3b3b 5.83 MiB 6.28 MiB 462.33 KiB
793f4dc 7.86 MiB 9.44 MiB 1.58 MiB
667e3c4 5.83 MiB 6.28 MiB 459.83 KiB
f579250 5.66 MiB 6.09 MiB 448.36 KiB
2d65d04 5.73 MiB 6.17 MiB 455.42 KiB
e0c8591 5.53 MiB 5.96 MiB 444.86 KiB
93b7728 7.86 MiB 9.44 MiB 1.58 MiB
640ad0c 7.86 MiB 9.44 MiB 1.58 MiB
d052aef 5.73 MiB 6.17 MiB 453.76 KiB

Previous results on branch: buenaflor/fix/rate-limit-categories

Startup times

Revision Plain With Sentry Diff
3743ad4 1258.00 ms 1256.88 ms -1.12 ms

App size

Revision Plain With Sentry Diff
3743ad4 5.83 MiB 6.28 MiB 459.62 KiB

@buenaflor
buenaflor merged commit 565fb48 into main Jul 2, 2026
155 of 156 checks passed
@buenaflor
buenaflor deleted the buenaflor/fix/rate-limit-categories branch July 2, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review and update Rate Limiting data categories for sentry-dart

3 participants