Repository navigation
Keep DD_SPAN_TAGS when remote config overrides tracing tags (OTLP trace/resource-level split) #12937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dougqh
wants to merge
3
commits into
dougqh/rc-tracing-tags-tests
Choose a base branch
from
dougqh/split-global-span-tags
base: dougqh/rc-tracing-tags-tests
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
−17
Open
Keep DD_SPAN_TAGS when remote config overrides tracing tags (OTLP trace/resource-level split) #12937
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,11 +221,12 @@ private static final class LocalRootSpanTags { | |
| */ | ||
| private final boolean apmTracingEnabled; | ||
|
|
||
| /** A set of tags that are added to every span */ | ||
| /** | ||
| * Span defaults added to every span: {@code DD_SPAN_TAGS}, or the tags given to the builder. | ||
| * Unlike the global tags ({@code DD_TAGS}), remote config doesn't replace these. | ||
| */ | ||
| private final TagMap defaultSpanTags; | ||
|
|
||
| private final boolean defaultSpanTagsNeedsIntercept; | ||
|
|
||
| /** number of spans in a pending trace before they get flushed */ | ||
| private final int partialFlushMinSpans; | ||
|
|
||
|
|
@@ -543,7 +544,7 @@ public CoreTracerBuilder config(final Config config) { | |
| invertMap(config.getBaggageMapping()))); | ||
| // Explicitly skip setting scope manager because it depends on statsDClient | ||
| localRootSpanTags(config.getLocalRootSpanTags()); | ||
| defaultSpanTags(withTracerTags(config.getMergedSpanTags(), config, null)); | ||
| defaultSpanTags(config.getSpanTags()); | ||
| serviceNameMappings(config.getServiceMapping()); | ||
| taggedHeaders(config.getRequestHeaderTags()); | ||
| baggageMapping(config.getBaggageMapping()); | ||
|
|
@@ -737,7 +738,6 @@ private CoreTracer( | |
| null == tagInterceptor ? new TagInterceptor(new RuleFlags(config)) : tagInterceptor; | ||
|
|
||
| this.defaultSpanTags = defaultSpanTags; | ||
| this.defaultSpanTagsNeedsIntercept = this.tagInterceptor.needsIntercept(this.defaultSpanTags); | ||
|
|
||
| this.dynamicConfig = | ||
| DynamicConfig.create(ConfigSnapshot::new) | ||
|
|
@@ -751,7 +751,7 @@ private CoreTracer( | |
| .setTraceSampleRate(config.getTraceSampleRate()) | ||
| .setSpanSamplingRules(spanSamplingRules.getRules()) | ||
| .setTraceSamplingRules(traceSamplingRules.getRules(), traceSamplingRulesJson) | ||
| .setTracingTags(config.getMergedSpanTags()) | ||
| .setTracingTags(config.getGlobalTags()) | ||
| .setDataStreamsTransactionExtractors(dataStreamsTransactionExtractors.getExtractors()) | ||
| .apply(); | ||
|
|
||
|
|
@@ -2590,7 +2590,25 @@ public void run() { | |
| protected class ConfigSnapshot extends DynamicConfig.Snapshot { | ||
| final Sampler sampler; | ||
|
|
||
| /** | ||
| * The global tags ({@code DD_TAGS}, or their remote-config override), as given. These are what | ||
| * an OTLP export carries as resource attributes. | ||
| */ | ||
| final TagMap globalTags; | ||
|
|
||
| /** | ||
| * The span defaults with the tracer-defined tags ({@code env}, {@code _dd.dsm.enabled}, ...), | ||
| * but without the global tags. | ||
| */ | ||
| final TagMap spanDefaultTags; | ||
|
|
||
| /** | ||
| * The tags every span starts with: the global tags merged with the span defaults (span defaults | ||
| * win), then given the tracer-defined tags. {@code version} is dropped here even when it's a | ||
| * global tag, unless it's a split-by tag. | ||
| */ | ||
| final TagMap mergedTracerTags; | ||
|
|
||
| final boolean mergedTracerTagsNeedsIntercept; | ||
|
|
||
| protected ConfigSnapshot( | ||
|
|
@@ -2607,14 +2625,22 @@ protected ConfigSnapshot( | |
| sampler = Sampler.Builder.forConfig(CoreTracer.this.initialConfig, this, agentSampler); | ||
| } | ||
|
|
||
| if (null == oldSnapshot) { | ||
| mergedTracerTags = CoreTracer.this.defaultSpanTags.immutableCopy(); | ||
| this.mergedTracerTagsNeedsIntercept = CoreTracer.this.defaultSpanTagsNeedsIntercept; | ||
| } else if (getTracingTags().equals(oldSnapshot.getTracingTags())) { | ||
| if (null != oldSnapshot && getTracingTags().equals(oldSnapshot.getTracingTags())) { | ||
| globalTags = oldSnapshot.globalTags; | ||
| spanDefaultTags = oldSnapshot.spanDefaultTags; | ||
| mergedTracerTags = oldSnapshot.mergedTracerTags; | ||
| mergedTracerTagsNeedsIntercept = oldSnapshot.mergedTracerTagsNeedsIntercept; | ||
| } else { | ||
| mergedTracerTags = withTracerTags(getTracingTags(), CoreTracer.this.initialConfig, this); | ||
| Config config = CoreTracer.this.initialConfig; | ||
| TagMap defaultSpanTags = CoreTracer.this.defaultSpanTags; | ||
| globalTags = TagMap.fromMapImmutable(getTracingTags()); | ||
| spanDefaultTags = withTracerTags(defaultSpanTags, config, this); | ||
|
|
||
| // span defaults take precedence over global tags | ||
| TagMap userSpanTags = TagMap.create(globalTags.size() + defaultSpanTags.size()); | ||
| userSpanTags.putAll(globalTags); | ||
| userSpanTags.putAll(defaultSpanTags); | ||
| mergedTracerTags = withTracerTags(userSpanTags, config, this); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the existing order of |
||
| mergedTracerTagsNeedsIntercept = | ||
| CoreTracer.this.tagInterceptor.needsIntercept(mergedTracerTags); | ||
| } | ||
|
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post RC snapshot, we lose information of
envandversionwhen we initially store it in tags. Does it make sense to retain this info post RC?