Skip to content

Commit f2315e3

Browse files
committed
finish moving logic into advicescope class
1 parent a6220e8 commit f2315e3

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

instrumentation/play/play-mvc/play-mvc-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
99
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
1010
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
11-
import static io.opentelemetry.javaagent.instrumentation.play.v2_4.Play24Singletons.updateSpan;
1211
import static net.bytebuddy.matcher.ElementMatchers.named;
1312
import static net.bytebuddy.matcher.ElementMatchers.returns;
1413
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@@ -70,12 +69,8 @@ public static void stopTraceOnResponse(
7069
if (actionScope == null) {
7170
return;
7271
}
73-
actionScope.closeScope();
7472

75-
updateSpan(actionScope.getContext(), req);
76-
77-
// span finished in RequestCompleteCallback
78-
actionScope.end(throwable, responseFuture, (Action<?>) thisAction);
73+
actionScope.end(throwable, responseFuture, (Action<?>) thisAction, req);
7974
}
8075
}
8176
}

instrumentation/play/play-mvc/play-mvc-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/AdviceScope.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
package io.opentelemetry.javaagent.instrumentation.play.v2_4;
77

88
import static io.opentelemetry.javaagent.instrumentation.play.v2_4.Play24Singletons.instrumenter;
9+
import static io.opentelemetry.javaagent.instrumentation.play.v2_4.Play24Singletons.updateSpan;
910

1011
import io.opentelemetry.context.Context;
1112
import io.opentelemetry.context.Scope;
1213
import javax.annotation.Nullable;
1314
import play.api.mvc.Action;
15+
import play.api.mvc.Request;
1416
import play.api.mvc.Result;
1517
import scala.concurrent.Future;
1618

@@ -27,10 +29,6 @@ public AdviceScope(Context context, Scope scope, ActionData actionData) {
2729
this.scope = scope;
2830
}
2931

30-
public Context getContext() {
31-
return context;
32-
}
33-
3432
@Nullable
3533
public static AdviceScope start(Context parentContext, ActionData actionData) {
3634
if (!instrumenter().shouldStart(parentContext, actionData)) {
@@ -47,12 +45,15 @@ public void closeScope() {
4745
}
4846
}
4947

50-
public void end(Throwable throwable, Future<Result> responseFuture, Action<?> thisAction) {
48+
public void end(
49+
Throwable throwable, Future<Result> responseFuture, Action<?> thisAction, Request<?> req) {
5150
closeScope();
51+
updateSpan(context, req);
5252

5353
if (throwable == null) {
54+
// span finished in RequestCompleteCallback
5455
responseFuture.onComplete(
55-
new RequestCompleteCallback(getContext()), thisAction.executionContext());
56+
new RequestCompleteCallback(context), thisAction.executionContext());
5657
} else {
5758
instrumenter().end(context, actionData, null, throwable);
5859
}

0 commit comments

Comments
 (0)