Skip to content

Commit 4d345ea

Browse files
committed
Extracting static version of startSpan
1 parent 89ff968 commit 4d345ea

File tree

1 file changed

+74
-3
lines changed

1 file changed

+74
-3
lines changed

dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,10 +1553,33 @@ public final CoreSpanBuilder ignoreActiveSpan() {
15531553
return this;
15541554
}
15551555

1556+
@Deprecated
15561557
protected final DDSpan buildSpan() {
15571558
return buildSpan(tracer, instrumentationName, timestampMicro, links, buildSpanContext());
15581559
}
15591560

1561+
protected static final DDSpan buildSpan(
1562+
final CoreTracer tracer,
1563+
long spanId,
1564+
String instrumentationName,
1565+
long timestampMicro,
1566+
String serviceName,
1567+
CharSequence operationName,
1568+
String resourceName,
1569+
AgentSpanContext incomingParentContext,
1570+
boolean ignoreScope,
1571+
boolean errorFlag,
1572+
CharSequence spanType,
1573+
TagMap.Ledger tagLedger,
1574+
List<AgentSpanLink> links,
1575+
Object builderRequestContextDataAppSec,
1576+
Object builderRequestContextDataIast,
1577+
Object builderCiVisibilityContextData)
1578+
{
1579+
return buildSpan(tracer, instrumentationName, timestampMicro, links,
1580+
buildSpanContext(tracer, spanId, serviceName, operationName, resourceName, incomingParentContext, ignoreScope, errorFlag, spanType, tagLedger, links, builderRequestContextDataAppSec, builderRequestContextDataIast, builderCiVisibilityContextData));
1581+
}
1582+
15601583
protected static final DDSpan buildSpan(
15611584
CoreTracer tracer,
15621585
String instrumentationName,
@@ -1625,11 +1648,11 @@ protected static final List<AgentSpanLink> addLinks(
16251648
links.addAll(additionalLinks);
16261649
}
16271650
return links;
1628-
}
1651+
}
16291652

16301653
@Override
1631-
public abstract AgentSpan start();
1632-
1654+
public abstract AgentSpan start();
1655+
16331656
protected AgentSpan startImpl() {
16341657
AgentSpanContext pc = parent;
16351658
if (pc == null && !ignoreScope) {
@@ -1645,6 +1668,54 @@ protected AgentSpan startImpl() {
16451668
return buildSpan();
16461669
}
16471670

1671+
protected static final AgentSpan startSpan(
1672+
final CoreTracer tracer,
1673+
long spanId,
1674+
String instrumentationName,
1675+
long timestampMicro,
1676+
String serviceName,
1677+
CharSequence operationName,
1678+
String resourceName,
1679+
AgentSpanContext incomingParentContext,
1680+
boolean ignoreScope,
1681+
boolean errorFlag,
1682+
CharSequence spanType,
1683+
TagMap.Ledger tagLedger,
1684+
List<AgentSpanLink> links,
1685+
Object builderRequestContextDataAppSec,
1686+
Object builderRequestContextDataIast,
1687+
Object builderCiVisibilityContextData)
1688+
{
1689+
AgentSpanContext pc = incomingParentContext;
1690+
if (pc == null && !ignoreScope) {
1691+
final AgentSpan span = tracer.activeSpan();
1692+
if (span != null) {
1693+
pc = span.context();
1694+
}
1695+
}
1696+
1697+
if (pc == BlackHoleSpan.Context.INSTANCE) {
1698+
return new BlackHoleSpan(pc.getTraceId());
1699+
}
1700+
return buildSpan(
1701+
tracer,
1702+
spanId,
1703+
instrumentationName,
1704+
timestampMicro,
1705+
serviceName,
1706+
operationName,
1707+
resourceName,
1708+
incomingParentContext,
1709+
ignoreScope,
1710+
errorFlag,
1711+
spanType,
1712+
tagLedger,
1713+
links,
1714+
builderRequestContextDataAppSec,
1715+
builderRequestContextDataIast,
1716+
builderCiVisibilityContextData);
1717+
}
1718+
16481719
@Override
16491720
public final CoreSpanBuilder withTag(final String tag, final Number number) {
16501721
return withTag(tag, (Object) number);

0 commit comments

Comments
 (0)