Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import datadog.trace.bootstrap.instrumentation.api.ProfilingContextIntegration;
import datadog.trace.bootstrap.instrumentation.api.SpanAttributes;
import datadog.trace.bootstrap.instrumentation.api.SpanLink;
import datadog.trace.bootstrap.instrumentation.api.SpanPrototype;
import datadog.trace.bootstrap.instrumentation.api.TagContext;
import datadog.trace.bootstrap.instrumentation.api.Tags;
import datadog.trace.civisibility.interceptor.CiVisibilityApmProtocolInterceptor;
Expand Down Expand Up @@ -1583,6 +1584,7 @@ public abstract static class CoreSpanBuilder implements AgentTracer.SpanBuilder
// Builder attributes
// Make sure any fields added here are also reset properly in ReusableSingleSpanBuilder.reset
protected TagMap.Ledger tagLedger;
protected SpanPrototype spanPrototype = SpanPrototype.NONE;
protected long timestampMicro;
protected AgentSpanContext parent;
protected String serviceName;
Expand Down Expand Up @@ -1621,6 +1623,7 @@ protected static final DDSpan buildSpan(
boolean errorFlag,
CharSequence spanType,
TagMap.Ledger tagLedger,
SpanPrototype spanPrototype,
List<AgentSpanLink> links,
Object builderRequestContextDataAppSec,
Object builderRequestContextDataIast,
Expand All @@ -1640,6 +1643,7 @@ protected static final DDSpan buildSpan(
errorFlag,
spanType,
tagLedger,
spanPrototype,
links,
builderRequestContextDataAppSec,
builderRequestContextDataIast,
Expand Down Expand Up @@ -1725,6 +1729,7 @@ protected AgentSpan startImpl() {
this.errorFlag,
this.spanType,
this.tagLedger,
this.spanPrototype,
this.links,
this.builderRequestContextDataAppSec,
this.builderRequestContextDataIast,
Expand All @@ -1751,6 +1756,7 @@ protected static final AgentSpan startSpan(
false /* errorFlag */,
null /* spanType */,
null /* tagLedger */,
SpanPrototype.NONE /* spanPrototype */,
null /* links */,
null /* appSec */,
null /* iast */,
Expand All @@ -1770,6 +1776,7 @@ protected static final AgentSpan startSpan(
boolean errorFlag,
CharSequence spanType,
TagMap.Ledger tagLedger,
SpanPrototype spanPrototype,
List<AgentSpanLink> links,
Object builderRequestContextDataAppSec,
Object builderRequestContextDataIast,
Expand Down Expand Up @@ -1820,6 +1827,7 @@ protected static final AgentSpan startSpan(
errorFlag,
spanType,
tagLedger,
spanPrototype,
links,
builderRequestContextDataAppSec,
builderRequestContextDataIast,
Expand Down Expand Up @@ -1908,6 +1916,11 @@ public final CoreSpanBuilder withTag(final String tag, final Object value) {
return this;
}

public final CoreSpanBuilder withSpanPrototype(final SpanPrototype spanPrototype) {
this.spanPrototype = (spanPrototype == null) ? SpanPrototype.NONE : spanPrototype;
return this;
}

@Override
public final <T> AgentTracer.SpanBuilder withRequestContextData(
RequestContextSlot slot, T data) {
Expand Down Expand Up @@ -1958,6 +1971,7 @@ protected static final DDSpanContext buildSpanContext(
boolean errorFlag,
CharSequence spanType,
TagMap.Ledger tagLedger,
SpanPrototype spanPrototype,
List<AgentSpanLink> links,
Object builderRequestContextDataAppSec,
Object builderRequestContextDataIast,
Expand Down Expand Up @@ -2196,6 +2210,9 @@ protected static final DDSpanContext buildSpanContext(
// the builder. This is the order that the tags were added previously, but maybe the `tags`
// set in the builder should come last, so that they override other tags.
context.setAllTags(mergedTracerTags, mergedTracerTagsNeedsIntercept);
if (spanPrototype != SpanPrototype.NONE) {
context.setAllTags(spanPrototype.tags());
}
context.setAllTags(tagLedger);
context.setAllTags(coreTags, coreTagsNeedsIntercept);
context.setAllTags(rootSpanTags, rootSpanTagsNeedsIntercept);
Expand Down Expand Up @@ -2276,6 +2293,7 @@ final boolean reset(String instrumentationName, CharSequence operationName) {
this.operationName = operationName;

if (this.tagLedger != null) this.tagLedger.reset();
this.spanPrototype = SpanPrototype.NONE;
this.timestampMicro = 0L;
this.parent = null;
this.serviceName = null;
Expand Down
Loading