Skip to content

Commit e585f56

Browse files
committed
fix indy convertsion
1 parent 9324fbc commit e585f56

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static void stopTraceOnResponse(
9797
@Advice.This Action<?> thisAction,
9898
@Advice.Thrown Throwable throwable,
9999
@Advice.Argument(0) Request<?> req,
100-
@Advice.Return(readOnly = false) Future<Result> responseFuture,
100+
@Advice.Return Future<Result> responseFuture,
101101
@Advice.Enter @Nullable AdviceScope actionScope) {
102102
if (actionScope == null) {
103103
return;

instrumentation/play/play-mvc/play-mvc-2.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_6/ActionInstrumentation.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
1010
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
1111
import static io.opentelemetry.javaagent.instrumentation.play.v2_6.Play26Singletons.instrumenter;
12+
import static io.opentelemetry.javaagent.instrumentation.play.v2_6.Play26Singletons.updateSpan;
1213
import static net.bytebuddy.matcher.ElementMatchers.named;
1314
import static net.bytebuddy.matcher.ElementMatchers.returns;
1415
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@@ -68,23 +69,25 @@ public static AdviceScope start(Context parentContext) {
6869
return new AdviceScope(context, context.makeCurrent());
6970
}
7071

71-
public void end(
72+
public Future<Result> end(
7273
@Nullable Throwable throwable,
7374
Future<Result> responseFuture,
7475
Action<?> thisAction,
7576
Request<?> req) {
7677
scope.close();
78+
updateSpan(context, req);
7779

7880
if (throwable == null) {
7981
// span is finished when future completes
8082
// not using responseFuture.onComplete() because that doesn't guarantee this handler span
8183
// will be completed before the server span completes
8284
responseFuture =
83-
ResponseFutureWrapper.wrap(
84-
responseFuture, context, thisAction.executionContext(), req);
85+
ResponseFutureWrapper.wrap(responseFuture, context, thisAction.executionContext());
8586
} else {
8687
instrumenter().end(context, null, null, throwable);
8788
}
89+
90+
return responseFuture;
8891
}
8992
}
9093

@@ -94,17 +97,18 @@ public static AdviceScope onEnter(@Advice.Argument(0) Request<?> req) {
9497
}
9598

9699
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
97-
public static void stopTraceOnResponse(
100+
@Advice.AssignReturned.ToReturned
101+
public static Future<Result> stopTraceOnResponse(
98102
@Advice.This Action<?> thisAction,
99103
@Advice.Thrown Throwable throwable,
100104
@Advice.Argument(0) Request<?> req,
101-
@Advice.Return(readOnly = false) Future<Result> responseFuture,
105+
@Advice.Return Future<Result> responseFuture,
102106
@Advice.Enter @Nullable AdviceScope actionScope) {
103107
if (actionScope == null) {
104-
return;
108+
return responseFuture;
105109
}
106110

107-
actionScope.end(throwable, responseFuture, thisAction, req);
111+
return actionScope.end(throwable, responseFuture, thisAction, req);
108112
}
109113
}
110114
}

instrumentation/play/play-mvc/play-mvc-2.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_6/ResponseFutureWrapper.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
package io.opentelemetry.javaagent.instrumentation.play.v2_6;
77

88
import static io.opentelemetry.javaagent.instrumentation.play.v2_6.Play26Singletons.instrumenter;
9-
import static io.opentelemetry.javaagent.instrumentation.play.v2_6.Play26Singletons.updateSpan;
109

1110
import com.google.errorprone.annotations.CanIgnoreReturnValue;
1211
import io.opentelemetry.context.Context;
13-
import play.api.mvc.Request;
1412
import play.api.mvc.Result;
1513
import scala.concurrent.ExecutionContext;
1614
import scala.concurrent.Future;
@@ -19,14 +17,13 @@
1917
public final class ResponseFutureWrapper {
2018

2119
public static Future<Result> wrap(
22-
Future<Result> future, Context context, ExecutionContext executionContext, Request<?> req) {
20+
Future<Result> future, Context context, ExecutionContext executionContext) {
2321

2422
return future.transform(
2523
new AbstractFunction1<Result, Result>() {
2624
@Override
2725
@CanIgnoreReturnValue
2826
public Result apply(Result result) {
29-
updateSpan(context, req);
3027
instrumenter().end(context, null, null, null);
3128
return result;
3229
}
@@ -35,7 +32,6 @@ public Result apply(Result result) {
3532
@Override
3633
@CanIgnoreReturnValue
3734
public Throwable apply(Throwable throwable) {
38-
updateSpan(context, req);
3935
instrumenter().end(context, null, null, throwable);
4036
return throwable;
4137
}

0 commit comments

Comments
 (0)