File tree Expand file tree Collapse file tree 2 files changed +25
-17
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 +25
-17
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 .javadsl .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 1414import net .bytebuddy .matcher .ElementMatcher ;
1515import org .apache .pekko .http .javadsl .server .RouteResult ;
1616import org .apache .pekko .http .scaladsl .server .RequestContext ;
17- import scala .PartialFunction ;
18- import scala .Unit ;
1917import scala .concurrent .Future ;
20- import scala .util .Try ;
2118
2219public class RouteConcatenationInstrumentation implements TypeInstrumentation {
2320 @ Override
@@ -33,19 +30,6 @@ public void transform(TypeTransformer transformer) {
3330 named ("$anonfun$$tilde$2" ), this .getClass ().getName () + "$Apply2Advice" );
3431 }
3532
36- public static class OnExitFinalizer implements PartialFunction <Try <RouteResult >, Unit > {
37- @ Override
38- public boolean isDefinedAt (Try <RouteResult > x ) {
39- return true ;
40- }
41-
42- @ Override
43- public Unit apply (Try <RouteResult > v1 ) {
44- PekkoRouteHolder .restore ();
45- return null ;
46- }
47- }
48-
4933 @ SuppressWarnings ("unused" )
5034 public static class ApplyAdvice {
5135
@@ -61,7 +45,7 @@ public static void onEnter() {
6145 public static void onExit (
6246 @ Advice .Argument (value = 2 ) RequestContext ctx ,
6347 @ Advice .Return (readOnly = false ) Future <RouteResult > fut ) {
64- fut = fut .andThen (new OnExitFinalizer (), ctx .executionContext ());
48+ fut = fut .andThen (new RestoreOnExit (), ctx .executionContext ());
6549 }
6650 }
6751
You can’t perform that action at this time.
0 commit comments