Skip to content

Commit 4c2a2f5

Browse files
mccullsmtoffl01
authored andcommitted
Remove AgentScope.source() from instrumentation API (#8539)
1 parent 89286d7 commit 4c2a2f5

File tree

8 files changed

+25
-35
lines changed

8 files changed

+25
-35
lines changed

dd-java-agent/instrumentation/opentracing/api-0.31/src/main/java/datadog/trace/instrumentation/opentracing31/OTScopeManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public AgentSpan span() {
8989
return agentSpan;
9090
}
9191

92-
@Override
93-
public byte source() {
94-
return ScopeSource.MANUAL.id();
95-
}
96-
9792
@Override
9893
public void close() {
9994
if (agentSpan == tracer.activeSpan()) {

dd-java-agent/instrumentation/opentracing/api-0.32/src/main/java/datadog/trace/instrumentation/opentracing32/OTScopeManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ public AgentSpan span() {
9999
return agentSpan;
100100
}
101101

102-
@Override
103-
public byte source() {
104-
return ScopeSource.MANUAL.id();
105-
}
106-
107102
@Override
108103
public void close() {
109104
if (agentSpan == tracer.activeSpan()) {

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -922,12 +922,7 @@ public AgentScope activateSpan(AgentSpan span, ScopeSource source, boolean isAsy
922922

923923
@Override
924924
public AgentScope.Continuation captureActiveSpan() {
925-
AgentScope activeScope = this.scopeManager.active();
926-
if (null != activeScope && activeScope.isAsyncPropagating()) {
927-
return scopeManager.captureSpan(activeScope.span(), activeScope.source());
928-
} else {
929-
return AgentTracer.noopContinuation();
930-
}
925+
return scopeManager.captureActiveSpan();
931926
}
932927

933928
@Override
@@ -937,16 +932,12 @@ public AgentScope.Continuation captureSpan(final AgentSpan span) {
937932

938933
@Override
939934
public boolean isAsyncPropagationEnabled() {
940-
AgentScope activeScope = this.scopeManager.active();
941-
return activeScope != null && activeScope.isAsyncPropagating();
935+
return scopeManager.isAsyncPropagationEnabled();
942936
}
943937

944938
@Override
945939
public void setAsyncPropagationEnabled(boolean asyncPropagationEnabled) {
946-
AgentScope activeScope = this.scopeManager.active();
947-
if (activeScope != null) {
948-
activeScope.setAsyncPropagation(asyncPropagationEnabled);
949-
}
940+
scopeManager.setAsyncPropagationEnabled(asyncPropagationEnabled);
950941
}
951942

952943
@Override

dd-trace-core/src/main/java/datadog/trace/core/scopemanager/ContinuableScope.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ public final void afterActivated() {
184184
}
185185
}
186186

187-
@Override
188187
public byte source() {
189188
return (byte) (source & 0x7F);
190189
}

dd-trace-core/src/main/java/datadog/trace/core/scopemanager/ContinuableScopeManager.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import datadog.trace.api.scopemanager.ScopeListener;
1414
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
1515
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
16+
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
1617
import datadog.trace.bootstrap.instrumentation.api.ProfilerContext;
1718
import datadog.trace.bootstrap.instrumentation.api.ProfilingContextIntegration;
1819
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
@@ -90,6 +91,15 @@ public AgentScope activate(
9091
return activate(span, source.id(), true, isAsyncPropagating);
9192
}
9293

94+
public AgentScope.Continuation captureActiveSpan() {
95+
ContinuableScope activeScope = scopeStack().active();
96+
if (null != activeScope && activeScope.isAsyncPropagating()) {
97+
return captureSpan(activeScope.span(), activeScope.source());
98+
} else {
99+
return AgentTracer.noopContinuation();
100+
}
101+
}
102+
93103
public AgentScope.Continuation captureSpan(final AgentSpan span, byte source) {
94104
ScopeContinuation continuation = new ScopeContinuation(this, span, source);
95105
continuation.register();
@@ -166,6 +176,18 @@ ContinuableScope continueSpan(
166176
return scope;
167177
}
168178

179+
public boolean isAsyncPropagationEnabled() {
180+
ContinuableScope activeScope = scopeStack().active();
181+
return activeScope != null && activeScope.isAsyncPropagating();
182+
}
183+
184+
public void setAsyncPropagationEnabled(boolean asyncPropagationEnabled) {
185+
ContinuableScope activeScope = scopeStack().active();
186+
if (activeScope != null) {
187+
activeScope.setAsyncPropagation(asyncPropagationEnabled);
188+
}
189+
}
190+
169191
public void closePrevious(final boolean finishSpan) {
170192
ScopeStack scopeStack = scopeStack();
171193

dd-trace-ot/src/main/java/datadog/opentracing/OTScopeManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ public AgentSpan span() {
117117
return agentSpan;
118118
}
119119

120-
@Override
121-
public byte source() {
122-
return ScopeSource.MANUAL.id();
123-
}
124-
125120
@Override
126121
public void close() {
127122
if (agentSpan == tracer.activeSpan()) {

internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentScope.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
public interface AgentScope extends TraceScope, Closeable {
77
AgentSpan span();
88

9-
byte source();
10-
119
@Override
1210
void close();
1311

internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/NoopScope.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ public AgentSpan span() {
1010
return NoopSpan.INSTANCE;
1111
}
1212

13-
@Override
14-
public byte source() {
15-
return 0;
16-
}
17-
1813
@Override
1914
public Continuation capture() {
2015
return NoopContinuation.INSTANCE;

0 commit comments

Comments
 (0)