Skip to content

Commit 1ef67e5

Browse files
authored
Fold setAsyncPropagation into preceding activateSpan (#8032)
1 parent d949e28 commit 1ef67e5

File tree

65 files changed

+82
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+82
-184
lines changed

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ public TestImpl(
9898

9999
span = spanBuilder.start();
100100

101-
final AgentScope scope = activateSpan(span);
102-
scope.setAsyncPropagation(true);
101+
activateSpan(span, true);
103102

104103
span.setSpanType(InternalSpanTypes.TEST);
105104
span.setTag(Tags.SPAN_KIND, Tags.SPAN_KIND_TEST);

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/domain/TestSuiteImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ public TestSuiteImpl(
121121
testDecorator.afterStart(span);
122122

123123
if (!parallelized) {
124-
final AgentScope scope = activateSpan(span);
125-
scope.setAsyncPropagation(true);
124+
activateSpan(span, true);
126125
}
127126

128127
metricCollector.add(CiVisibilityCountMetric.EVENT_CREATED, 1, instrumentation, EventType.SUITE);

dd-java-agent/instrumentation/akka-concurrent/src/test/java/LinearTask.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ protected Integer compute() {
3232
} else {
3333
int next = parent + 1;
3434
AgentSpan span = startSpan(Integer.toString(next));
35-
try (AgentScope scope = activateSpan(span)) {
36-
// shouldn't be necessary with a decent API
37-
scope.setAsyncPropagation(true);
35+
try (AgentScope scope = activateSpan(span, true)) {
3836
LinearTask child = new LinearTask(next, depth);
3937
return child.fork().join();
4038
} finally {

dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/DatadogWrapperHelper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ public static AgentScope createSpan(final HttpRequest request) {
1515
DECORATE.afterStart(span);
1616
DECORATE.onRequest(span, request, request, extractedContext);
1717

18-
final AgentScope scope = activateSpan(span);
19-
scope.setAsyncPropagation(true);
20-
return scope;
18+
return activateSpan(span, true);
2119
}
2220

2321
public static void finishSpan(final AgentSpan span, final HttpResponse response) {

dd-java-agent/instrumentation/finatra-2.9/src/main/java/datadog/trace/instrumentation/finatra/FinatraInstrumentation.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ public static AgentScope nameSpan(
7676
DECORATE.afterStart(span);
7777
span.setResourceName(DECORATE.className(clazz));
7878

79-
final AgentScope scope = activateSpan(span);
80-
scope.setAsyncPropagation(true);
81-
return scope;
79+
return activateSpan(span, true);
8280
}
8381

8482
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)

dd-java-agent/instrumentation/grizzly-2/src/main/java/datadog/trace/instrumentation/grizzly/GrizzlyHttpHandlerInstrumentation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ public static class HandleAdvice {
7878
DECORATE.afterStart(span);
7979
DECORATE.onRequest(span, request, request, parentContext);
8080

81-
scope = activateSpan(span);
82-
scope.setAsyncPropagation(true);
81+
scope = activateSpan(span, true);
8382

8483
request.setAttribute(DD_SPAN_ATTRIBUTE, span);
8584
request.setAttribute(CorrelationIdentifier.getTraceIdKey(), GlobalTracer.get().getTraceId());

dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/FilterAdvice.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,22 @@
77
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
88
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
99
import net.bytebuddy.asm.Advice;
10-
import org.glassfish.grizzly.filterchain.BaseFilter;
1110
import org.glassfish.grizzly.filterchain.FilterChainContext;
1211

1312
public class FilterAdvice {
1413

1514
@Advice.OnMethodEnter(suppress = Throwable.class)
16-
public static AgentScope onEnter(
17-
@Advice.This BaseFilter it, @Advice.Argument(0) final FilterChainContext ctx) {
18-
if (ctx.getAttributes().getAttribute(DD_SPAN_ATTRIBUTE) == null || activeSpan() != null) {
15+
public static AgentScope onEnter(@Advice.Argument(0) final FilterChainContext ctx) {
16+
Object span = ctx.getAttributes().getAttribute(DD_SPAN_ATTRIBUTE);
17+
if (span == null || activeSpan() != null) {
1918
return null;
2019
}
21-
AgentScope scope =
22-
activateSpan((AgentSpan) ctx.getAttributes().getAttribute(DD_SPAN_ATTRIBUTE));
23-
scope.setAsyncPropagation(true);
24-
return scope;
20+
return activateSpan((AgentSpan) span, true);
2521
}
2622

2723
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
28-
public static void onExit(@Advice.This BaseFilter it, @Advice.Enter final AgentScope scope) {
24+
public static void onExit(@Advice.Enter final AgentScope scope) {
2925
if (scope != null) {
30-
scope.setAsyncPropagation(false);
3126
scope.close();
3227
}
3328
}

dd-java-agent/instrumentation/grizzly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/GrizzlyDecorator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ public static NextAction onHttpCodecFilterExit(
115115
HttpResponsePacket httpResponse = httpRequest.getResponse();
116116
AgentSpan.Context.Extracted context = DECORATE.extract(httpRequest);
117117
AgentSpan span = DECORATE.startSpan(httpRequest, context);
118-
AgentScope scope = activateSpan(span);
119-
scope.setAsyncPropagation(true);
118+
AgentScope scope = activateSpan(span, true);
120119
DECORATE.afterStart(span);
121120
ctx.getAttributes().setAttribute(DD_SPAN_ATTRIBUTE, span);
122121
ctx.getAttributes().setAttribute(DD_RESPONSE_ATTRIBUTE, httpResponse);

dd-java-agent/instrumentation/ignite-2.0/src/main/java/datadog/trace/instrumentation/ignite/v2/cache/IgniteCacheAsyncInstrumentation.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,9 @@ public static AgentScope onEnter(
9191
span, InstrumentationContext.get(IgniteCache.class, Ignite.class).get(that));
9292
DECORATE.onOperation(span, that.getName(), methodName);
9393

94-
final AgentScope scope = activateSpan(span);
9594
// Enable async propagation, so the newly spawned task will be associated back with this
9695
// original trace.
97-
scope.setAsyncPropagation(true);
98-
return scope;
96+
return activateSpan(span, true);
9997
}
10098

10199
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
@@ -149,11 +147,9 @@ public static AgentScope onEnter(
149147
span, InstrumentationContext.get(IgniteCache.class, Ignite.class).get(that));
150148
DECORATE.onOperation(span, that.getName(), methodName, key);
151149

152-
final AgentScope scope = activateSpan(span);
153150
// Enable async propagation, so the newly spawned task will be associated back with this
154151
// original trace.
155-
scope.setAsyncPropagation(true);
156-
return scope;
152+
return activateSpan(span, true);
157153
}
158154

159155
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)

dd-java-agent/instrumentation/jakarta-rs-annotations-3/src/main/java/datadog/trace/instrumentation/jakarta3/DefaultRequestContextInstrumentation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public static AgentScope createGenericSpan(@Advice.This final ContainerRequestCo
4747
// can only be aborted inside the filter method
4848
}
4949

50-
final AgentScope scope = activateSpan(span);
51-
scope.setAsyncPropagation(true);
50+
final AgentScope scope = activateSpan(span, true);
5251

5352
DECORATE.afterStart(span);
5453
DECORATE.onJakartaRsSpan(span, parent, filterClass, method);

0 commit comments

Comments
 (0)