fix(tracer): use configurable MaxTagsHeaderLen for x-datadog-tags extraction#4727
Conversation
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: aeda5a9 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-05-05 20:12:41 Comparing candidate commit aeda5a9 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 138 metrics, 9 unstable metrics.
|
883c8a8 to
512397e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
ad4f91f to
e1ddf38
Compare
512397e to
404de05
Compare
- Adds a public `Config.MaxTagsHeaderLen()` getter on `internal/config.Config`. - Initialises the field in `loadConfig` from `DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH`, preserving the existing clamping semantics (negative -> 0; > MaxPropagatedTagsLength -> clamped down). - Adds `DefaultMaxTagsHeaderLen` and `MaxPropagatedTagsLength` exported constants in `internal/config`. - Removes the duplicate env resolution from `tracer/option.go` and the `defaultMaxTagsHeaderLen` / `maxPropagatedTagsLength` constants there. - The propagator is now constructed using `c.internalConfig.MaxTagsHeaderLen()` instead of locally re-reading the env var. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
e1ddf38 to
ae4e8d7
Compare
404de05 to
6bee9e8
Compare
…raction unmarshalPropagatingTags now uses the configured PropagatorConfig MaxTagsHeaderLen as the size cap on incoming x-datadog-tags headers instead of a hardcoded 512-byte constant. A non-positive MaxTagsHeaderLen disables extraction, mirroring the existing inject-side disable behavior. The DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH environment variable now governs both inject and extract. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
36684ad to
aeda5a9
Compare

What does this PR do?
unmarshalPropagatingTags(the extract path for thex-datadog-tagsheader) now uses the configuredMaxTagsHeaderLenas the size cap instead of a hardcoded 512-byte constant. A non-positiveMaxTagsHeaderLendisables extraction, mirroring the existing inject-side disable behavior. TheDD_TRACE_X_DATADOG_TAGS_MAX_LENGTHenvironment variable now governs both inject and extract.Motivation
The env var was previously respected only on inject; extract used a hardcoded 512-byte cap regardless of the configured value. This brings the two directions into alignment.