Skip to content

Commit de80454

Browse files
authored
Remove ScopeSource from instrumentation API (#8542)
* Migrate activateSpan calls with ScopeSource.MANUAL to activateManualSpan * Remove remaining references to ScopeSource from instrumentation API * Remove ScopeSource reference from test code
1 parent 2d31713 commit de80454

File tree

33 files changed

+64
-95
lines changed

33 files changed

+64
-95
lines changed

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerTracer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
99
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
1010
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
11-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
1211

1312
public class DebuggerTracer implements DebuggerContext.Tracer {
1413
public static final String OPERATION_NAME = "dd.dynamic.span";
@@ -36,7 +35,7 @@ public DebuggerSpan createSpan(String encodedProbeId, String resourceName, Strin
3635
dynamicSpan.setTag(tag.substring(0, idx), tag.substring(idx + 1));
3736
}
3837
}
39-
AgentScope scope = tracerAPI.activateSpan(dynamicSpan, ScopeSource.MANUAL);
38+
AgentScope scope = tracerAPI.activateManualSpan(dynamicSpan);
4039
return new DebuggerSpanImpl(dynamicSpan, scope, probeStatusSink, encodedProbeId);
4140
}
4241

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/probe/LogProbeTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
2828
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
2929
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI;
30-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
3130
import datadog.trace.bootstrap.instrumentation.api.Tags;
3231
import datadog.trace.core.CoreTracer;
3332
import java.util.stream.Stream;
@@ -137,7 +136,7 @@ private int runTrace(TracerAPI tracer, boolean captureSnapshot, Integer line, St
137136
if (sessionId != null) {
138137
span.setTag(Tags.PROPAGATED_DEBUG, sessionId + ":1");
139138
}
140-
try (AgentScope scope = tracer.activateSpan(span, ScopeSource.MANUAL)) {
139+
try (AgentScope scope = tracer.activateManualSpan(span)) {
141140
Builder builder =
142141
createLog("Budget testing").probeId(ProbeId.newId()).captureSnapshot(captureSnapshot);
143142
if (sessionId != null) {
@@ -178,7 +177,7 @@ private boolean fillSnapshot(DebugSessionStatus status) {
178177
CoreTracer.builder().idGenerationStrategy(IdGenerationStrategy.fromName("random")).build();
179178
AgentTracer.registerIfAbsent(tracer);
180179
AgentSpan span = tracer.startSpan("log probe debug session testing", "test span");
181-
try (AgentScope scope = tracer.activateSpan(span, ScopeSource.MANUAL)) {
180+
try (AgentScope scope = tracer.activateManualSpan(span)) {
182181
if (status == DebugSessionStatus.ACTIVE) {
183182
span.setTag(Tags.PROPAGATED_DEBUG, DEBUG_SESSION_ID + ":1");
184183
} else if (status == DebugSessionStatus.DISABLED) {

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CapturedSnapshot20.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
55
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
66
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
7-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
87
import datadog.trace.core.CoreTracer;
98

109
import java.util.Arrays;
@@ -26,7 +25,7 @@ public class CapturedSnapshot20 {
2625
public static int main(String arg) {
2726
AgentTracer.TracerAPI tracerAPI = AgentTracer.get();
2827
AgentSpan span = tracerAPI.buildSpan("process").start();
29-
try (AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL)) {
28+
try (AgentScope scope = tracerAPI.activateManualSpan(span)) {
3029
if (arg.equals("exception") || arg.equals("illegal")) {
3130
return new CapturedSnapshot20().processWithException(arg);
3231
}

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CapturedSnapshot21.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
55
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
66
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
7-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
87
import datadog.trace.core.CoreTracer;
98

109
import java.util.Arrays;
@@ -26,7 +25,7 @@ public class CapturedSnapshot21 {
2625
public static int main(String arg) {
2726
AgentTracer.TracerAPI tracerAPI = AgentTracer.get();
2827
AgentSpan span = tracerAPI.buildSpan("rootProcess").start();
29-
try (AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL)) {
28+
try (AgentScope scope = tracerAPI.activateManualSpan(span)) {
3029
return new CapturedSnapshot21().rootProcess(arg);
3130
} finally {
3231
span.finish();
@@ -36,7 +35,7 @@ public static int main(String arg) {
3635
private int rootProcess(String arg) {
3736
AgentTracer.TracerAPI tracerAPI = AgentTracer.get();
3837
AgentSpan span = tracerAPI.buildSpan("process1").start();
39-
try (AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL)) {
38+
try (AgentScope scope = tracerAPI.activateManualSpan(span)) {
4039
return process1(arg) + 1;
4140
} finally {
4241
span.finish();
@@ -46,7 +45,7 @@ private int rootProcess(String arg) {
4645
private int process1(String arg) {
4746
AgentTracer.TracerAPI tracerAPI = AgentTracer.get();
4847
AgentSpan span = tracerAPI.buildSpan("process2").start();
49-
try (AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL)) {
48+
try (AgentScope scope = tracerAPI.activateManualSpan(span)) {
5049
return process2(arg) + 1;
5150
} finally {
5251
span.finish();
@@ -56,7 +55,7 @@ private int process1(String arg) {
5655
private int process2(String arg) {
5756
AgentTracer.TracerAPI tracerAPI = AgentTracer.get();
5857
AgentSpan span = tracerAPI.buildSpan("process3").start();
59-
try (AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL)) {
58+
try (AgentScope scope = tracerAPI.activateManualSpan(span)) {
6059
return process3(arg) + 1;
6160
} finally {
6261
span.finish();

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CapturedSnapshot28.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
55
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
66
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
7-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
87
import datadog.trace.core.CoreTracer;
98

109
import java.util.Arrays;
@@ -27,7 +26,7 @@ public class CapturedSnapshot28 {
2726
public static int main(String arg) {
2827
AgentTracer.TracerAPI tracerAPI = AgentTracer.get();
2928
AgentSpan span = tracerAPI.buildSpan("process").start();
30-
try (AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL)) {
29+
try (AgentScope scope = tracerAPI.activateManualSpan(span)) {
3130
return new CapturedSnapshot28().process(arg);
3231
} finally {
3332
span.finish();

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CapturedSnapshot29.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
55
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
66
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
7-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
87
import datadog.trace.core.CoreTracer;
98

109
import java.util.Arrays;

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CodeOrigin01.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
66
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
77
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI;
8-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
98
import datadog.trace.core.DDSpan;
109

1110
public class CodeOrigin01 {
@@ -15,7 +14,7 @@ public class CodeOrigin01 {
1514

1615
public static int main(String arg) throws ReflectiveOperationException {
1716
AgentSpan span = newSpan("main");
18-
AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
17+
AgentScope scope = tracerAPI.activateManualSpan(span);
1918
if (arg.equals("debug_1")) {
2019
((DDSpan) span.getLocalRootSpan()).setTag("_dd.p.debug", "1");
2120
} else if (arg.equals("debug_0")) {
@@ -32,13 +31,13 @@ public static int main(String arg) throws ReflectiveOperationException {
3231

3332
private static void fullTrace() throws NoSuchMethodException {
3433
AgentSpan span = newSpan("entry");
35-
AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
34+
AgentScope scope = tracerAPI.activateManualSpan(span);
3635
entry();
3736
span.finish();
3837
scope.close();
3938

4039
span = newSpan("exit");
41-
scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
40+
scope = tracerAPI.activateManualSpan(span);
4241
exit();
4342
span.finish();
4443
scope.close();

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CodeOrigin02.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
66
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
77
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI;
8-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
98
import datadog.trace.core.DDSpan;
109

1110
public class CodeOrigin02 {
@@ -15,7 +14,7 @@ public class CodeOrigin02 {
1514

1615
public static int main(String arg) throws ReflectiveOperationException {
1716
AgentSpan span = newSpan("main");
18-
AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
17+
AgentScope scope = tracerAPI.activateManualSpan(span);
1918
if (arg.equals("debug_1")) {
2019
((DDSpan) span.getLocalRootSpan()).setTag("_dd.p.debug", "1");
2120
} else if (arg.equals("debug_0")) {
@@ -32,13 +31,13 @@ public static int main(String arg) throws ReflectiveOperationException {
3231

3332
private static void fullTrace() throws NoSuchMethodException {
3433
AgentSpan span = newSpan("entry");
35-
AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
34+
AgentScope scope = tracerAPI.activateManualSpan(span);
3635
entry();
3736
span.finish();
3837
scope.close();
3938

4039
span = newSpan("exit");
41-
scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
40+
scope = tracerAPI.activateManualSpan(span);
4241
exit();
4342
span.finish();
4443
scope.close();

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CodeOrigin03.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
66
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
77
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI;
8-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
98
import datadog.trace.core.DDSpan;
109

1110
public class CodeOrigin03 {
@@ -15,7 +14,7 @@ public class CodeOrigin03 {
1514

1615
public static int main(String arg) throws ReflectiveOperationException {
1716
AgentSpan span = newSpan("main");
18-
AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
17+
AgentScope scope = tracerAPI.activateManualSpan(span);
1918
if (arg.equals("debug_1")) {
2019
((DDSpan) span.getLocalRootSpan()).setTag("_dd.p.debug", "1");
2120
} else if (arg.equals("debug_0")) {
@@ -32,13 +31,13 @@ public static int main(String arg) throws ReflectiveOperationException {
3231

3332
private static void fullTrace() throws NoSuchMethodException {
3433
AgentSpan span = newSpan("entry");
35-
AgentScope scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
34+
AgentScope scope = tracerAPI.activateManualSpan(span);
3635
entry();
3736
span.finish();
3837
scope.close();
3938

4039
span = newSpan("exit");
41-
scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
40+
scope = tracerAPI.activateManualSpan(span);
4241
exit();
4342
span.finish();
4443
scope.close();

dd-java-agent/agent-debugger/src/test/resources/com/datadog/debugger/CodeOrigin04.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
55
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
66
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI;
7-
import datadog.trace.bootstrap.instrumentation.api.ScopeSource;
87

98
public class CodeOrigin04 {
109
private int intField = 42;
@@ -24,7 +23,7 @@ private static void doExit(int level) {
2423
AgentSpan span;
2524
AgentScope scope;
2625
span = newSpan("exit");
27-
scope = tracerAPI.activateSpan(span, ScopeSource.MANUAL);
26+
scope = tracerAPI.activateManualSpan(span);
2827
exit();
2928
span.finish();
3029
scope.close();

0 commit comments

Comments
 (0)