feat(sampling): accept Remote Config list-shape tags natively#2033
feat(sampling): accept Remote Config list-shape tags natively#2033bm1549 wants to merge 1 commit into
Conversation
SamplingRuleConfig::tags now accepts both the map shape
({"env": "prod"}) and the Remote Config wire shape
([{"key": "env", "value_glob": "prod"}]). List entries missing
"key" or "value_glob" produce a deserialization error — we don't
silently drop entries because doing so could broaden a tag-
constrained rule.
This removes the per-tracer normalize_rc_tags workaround. The
dd-trace-rs caller stops normalizing in a follow-up PR once
this lands in a libdatadog release.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
🔒 Cargo Deny Results📦
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2033 +/- ##
==========================================
+ Coverage 72.80% 72.87% +0.07%
==========================================
Files 458 458
Lines 75789 75856 +67
==========================================
+ Hits 55177 55280 +103
+ Misses 20612 20576 -36
🚀 New features to boost your workflow:
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: cdac292 | Docs | Datadog PR Page | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
What does this PR do?
Makes
libdd_sampling::SamplingRuleConfig::tagsaccept two wire shapes:{"env": "prod"}(current).[{"key": "env", "value_glob": "prod"}](new).Internally both normalize to
HashMap<String, String>. List entries missingkeyorvalue_globproduce a deserialization error. We don't silently drop bad entries because doing so could broaden a tag-constrained sampling rule.Motivation
Remote Config delivers
tracing_sampling_rulesentries with tags in the list shape. The previous#[serde(default)]ontagsonly accepted the map shape, so every tracer adoptinglibdd-samplinghas to normalize at the tracer ↔ libdatadog boundary. dd-trace-rs ships anormalize_rc_tagshelper for this. With this change, that workaround is no longer needed in any tracer.Additional Notes
tagsfield type staysHashMap<String, String>; only the deserializer is broader.serde::Deserializer::deserialize_any, which is safe for self-describing formats (JSON). Non-self-describing formats (bincode/postcard) would fail at deserialization time with a clear serde error.normalize_rc_tagsworkaround once this lands in a libdatadog release.How to test the change?
Four unit tests in
libdd-sampling/src/sampling_rule_config.rs:test_sampling_rule_config_tags_accepts_map_shape(regression).test_sampling_rule_config_tags_accepts_rc_list_shape.test_sampling_rule_config_tags_list_with_malformed_entry_rejects.test_sampling_rule_config_tags_absent_defaults_to_empty.Run:
cargo test -p libdd-sampling sampling_rule_config_tags.Integration verified locally against DataDog/dd-trace-rs#227: pointing dd-trace-rs at this branch and removing its
normalize_rc_tagsworkaround keeps all 352 dd-trace-rs tests green, including the handler-level tag tests that now traverse the upstream deserializer end-to-end.