feat: Add feature flags to hub span#3806
Conversation
Fixes scope feature flag updates so existing flags are refreshed as the newest entry before enforcing the 100-entry limit. This prevents full-buffer updates from dropping unrelated flags or shrinking the buffer, and adds regression coverage for the 100 most recent unique flags behavior.
Adds direct feature flag APIs to span-v2 spans, including add/remove support, span-local limit handling, and forwarding from Sentry.addFeatureFlag to the active span.
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Features
🤖 This preview updates automatically when you update the PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3806 +/- ##
==========================================
+ Coverage 87.22% 87.35% +0.13%
==========================================
Files 338 338
Lines 12250 12283 +33
==========================================
+ Hits 10685 10730 +45
+ Misses 1565 1553 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Replace feature flag contexts on update and copy them when cloning scopes, so flag mutations do not leak between parent and child scopes.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 234b2fa. Configure here.
# Conflicts: # packages/dart/lib/src/feature_flags_integration.dart # packages/dart/test/feature_flags_integration_test.dart
|
There are some failing tests |
# Conflicts: # packages/dart/lib/src/constants.dart
iOS Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 640ad0c | 1241.04 ms | 1253.96 ms | 12.92 ms |
| f11c8f8 | 1252.43 ms | 1250.17 ms | -2.25 ms |
| a7f011a | 1247.40 ms | 1255.72 ms | 8.32 ms |
| d0aa4b6 | 1268.23 ms | 1268.39 ms | 0.15 ms |
| 9d516f3 | 1256.04 ms | 1262.70 ms | 6.66 ms |
| bfabaf2 | 1251.72 ms | 1253.38 ms | 1.67 ms |
| 98b29fe | 1254.87 ms | 1259.38 ms | 4.51 ms |
| 737ef5d | 1255.65 ms | 1252.24 ms | -3.41 ms |
| 584a4b7 | 1235.62 ms | 1233.62 ms | -2.00 ms |
| 40c8f93 | 1234.27 ms | 1261.98 ms | 27.71 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 640ad0c | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| f11c8f8 | 5.83 MiB | 6.28 MiB | 462.27 KiB |
| a7f011a | 5.73 MiB | 6.17 MiB | 455.50 KiB |
| d0aa4b6 | 5.53 MiB | 6.02 MiB | 502.04 KiB |
| 9d516f3 | 5.73 MiB | 6.18 MiB | 463.54 KiB |
| bfabaf2 | 5.53 MiB | 6.01 MiB | 487.95 KiB |
| 98b29fe | 5.83 MiB | 6.28 MiB | 459.63 KiB |
| 737ef5d | 5.73 MiB | 6.18 MiB | 466.16 KiB |
| 584a4b7 | 5.66 MiB | 6.10 MiB | 451.31 KiB |
| 40c8f93 | 5.53 MiB | 6.00 MiB | 479.94 KiB |
Previous results on branch: feat/span-feature-flags
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| a132e96 | 1256.71 ms | 1263.96 ms | 7.24 ms |
| 6f8b651 | 1251.38 ms | 1257.29 ms | 5.92 ms |
| 234b2fa | 1257.63 ms | 1247.62 ms | -10.01 ms |
| a7d992a | 1236.11 ms | 1236.90 ms | 0.79 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| a132e96 | 5.83 MiB | 6.28 MiB | 459.63 KiB |
| 6f8b651 | 5.83 MiB | 6.28 MiB | 459.63 KiB |
| 234b2fa | 5.83 MiB | 6.28 MiB | 459.63 KiB |
| a7d992a | 5.83 MiB | 6.28 MiB | 459.63 KiB |
…eature-flags-hub-based Resolves conflicts with #3806 (feature flags on active spans), which landed on the removed FeatureFlagsIntegration: - Span forwarding (flag.evaluation.* attributes, 10-per-span cap) moves into Hub.addFeatureFlag, ahead of the scope buffer delegation. - The scope buffer fix from #3806 was already implemented in Scope.addFeatureFlag, no change needed. - Span tests from feature_flags_integration_test.dart are ported to hub_test.dart against the real Hub; end-to-end tests merged into sentry_test.dart unchanged. Co-Authored-By: Claude Fable 5 <[email protected]>

📜 Description
Adds feature flag evaluations to the currently active span through the hub when using Sentry.addFeatureFlag(...), without exposing feature flag APIs on spans directly.
💡 Motivation and Context
Closes #3766
💚 How did you test it?
Unit tests.
📝 Checklist
sendDefaultPiiis enabled