Read trace propagation behavior from tracer's config, not global singleton#11327
Closed
Read trace propagation behavior from tracer's config, not global singleton#11327
Conversation
…leton CoreSpanBuilder.startSpan was reading Config.get().getTracePropagationBehaviorExtract() from the global Config singleton on every remote-parent span build. The tracer's own configuration was already available via tracer.initialConfig, which is the consistent source used elsewhere in this file (line 841, ConfigSnapshot, etc.). Reading from the singleton has two consequences: - Span behavior depends on whatever the global Config is at build time, not on the tracer's configured behavior. Tracers built via withProperties(...) get a different Config from the singleton, and on master the override is silently ignored. - Extra getfield on a hot path. Marginal but unnecessary. Switch to tracer.initialConfig and add a regression test that builds a CoreTracer with a Properties override and verifies the resulting span reflects the override. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Another failed Claude experiment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CoreSpanBuilder.startSpanreadsConfig.get().getTracePropagationBehaviorExtract()for every remote-parent span build. Tracers configured viawithProperties(...)end up with aninitialConfigdistinct from the globalConfig.get()singleton, and on master the override is silently ignored — span behavior follows the singleton, not the tracer's configuration.This patch switches that one call site to
tracer.initialConfig.getTracePropagationBehaviorExtract(), matching the pattern already used elsewhere in this file (e.g. line 841 in the constructor, theConfigSnapshotclass, and the variousflush*methods that readinitialConfig). Marginal getfield savings on the hot path; the main benefit is correctness.Test plan
CoreSpanBuilderTest.extractBehaviorReadsTracerConfigNotGlobalSingleton:CoreTracerviatracerBuilder().withProperties(props).build()wherepropsselects RESTART.customTracer.initialConfigreflects the override.ExtractedContextparent and asserts RESTART behavior (parent dropped, parent context attached as a link).Config.get()returns CONTINUE, the parent isn't dropped, andassertNotEquals(extractedContext.getTraceId(), span.getTraceId())fails../gradlew :dd-trace-core:test --tests 'datadog.trace.core.CoreSpanBuilderTest'passes../gradlew :dd-trace-core:spotlessCheckpasses.🤖 Generated with Claude Code