feat: tag trace and current span with feature flag metadata#7764
feat: tag trace and current span with feature flag metadata#7764
Conversation
Overall package sizeSelf size: 4.98 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #7764 +/- ##
==========================================
- Coverage 80.36% 80.29% -0.08%
==========================================
Files 743 744 +1
Lines 32293 32327 +34
==========================================
+ Hits 25953 25957 +4
- Misses 6340 6370 +30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-03-13 21:33:34 Comparing candidate commit 4ff7e14 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 226 metrics, 34 unstable metrics. |
1e6d409 to
0e5892d
Compare
0e5892d to
4ff7e14
Compare
What does this PR do?
Attaches feature flag evaluation metadata to APM spans, enabling correlation between flag evaluations and traces.
When a flag is evaluated via the OpenFeature provider, we add tags on both the active span and trace with flag metadata (feature_flags..variant.key, feature_flags..subject.id).
Falls back to
String(result.value)as the variant when the provider returns no explicit variant (e.g., flag not found, default returned).Also enforces a configurable per-span limit on the number of flag tags to prevent bandwidth issues in traces with many evaluations
Motivation
Users of Datadog Feature Flagging + APM want to be able to filter APM traces by feature flag variant. These changes aim to enable that use case.
Additional Notes
Added config option:
DD_EXPERIMENTAL_FLAGGING_PROVIDER_MAX_FLAG_TAGS(default: 300) — maximum number of unique flag tags per span. Once reached, further evaluations still tag the current span, but skip tagging the trace.Testing
DD_EXPERIMENTAL_FLAGGING_PROVIDER_MAX_FLAG_TAGS=3DD_EXPERIMENTAL_FLAGGING_PROVIDER_MAX_FLAG_TAGS=50