File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
instrumentation/pekko/pekko-http-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/server/route Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright The OpenTelemetry Authors
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ package io .opentelemetry .javaagent .instrumentation .pekkohttp .v1_0 .server .route ;
7+
8+ import org .apache .pekko .http .scaladsl .server .RouteResult ;
9+ import scala .PartialFunction ;
10+ import scala .Unit ;
11+ import scala .util .Try ;
12+
13+ public class RestoreOnExit implements PartialFunction <Try <RouteResult >, Unit > {
14+ @ Override
15+ public boolean isDefinedAt (Try <RouteResult > x ) {
16+ return true ;
17+ }
18+
19+ @ Override
20+ public Unit apply (Try <RouteResult > v1 ) {
21+ PekkoRouteHolder .restore ();
22+ return null ;
23+ }
24+ }
Original file line number Diff line number Diff line change 1212import net .bytebuddy .asm .Advice ;
1313import net .bytebuddy .description .type .TypeDescription ;
1414import net .bytebuddy .matcher .ElementMatcher ;
15+ import org .apache .pekko .http .scaladsl .server .RequestContext ;
16+ import org .apache .pekko .http .scaladsl .server .RouteResult ;
17+ import scala .concurrent .Future ;
1518
1619public class RouteConcatenationInstrumentation implements TypeInstrumentation {
1720 @ Override
@@ -39,8 +42,10 @@ public static void onEnter() {
3942 }
4043
4144 @ Advice .OnMethodExit (onThrowable = Throwable .class , suppress = Throwable .class )
42- public static void onExit () {
43- PekkoRouteHolder .restore ();
45+ public static void onExit (
46+ @ Advice .Argument (value = 2 ) RequestContext ctx ,
47+ @ Advice .Return (readOnly = false ) Future <RouteResult > fut ) {
48+ fut = fut .andThen (new RestoreOnExit (), ctx .executionContext ());
4449 }
4550 }
4651
You can’t perform that action at this time.
0 commit comments