File tree Expand file tree Collapse file tree 2 files changed +20
-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 +20
-17
lines changed Original file line number Diff line number Diff line change 1+ package io .opentelemetry .javaagent .instrumentation .pekkohttp .v1_0 .server .route ;
2+
3+ import org .apache .pekko .http .javadsl .server .RouteResult ;
4+ import scala .PartialFunction ;
5+ import scala .Unit ;
6+ import scala .util .Try ;
7+
8+ public class RestoreOnExit implements PartialFunction <Try <RouteResult >, Unit > {
9+ @ Override
10+ public boolean isDefinedAt (Try <RouteResult > x ) {
11+ return true ;
12+ }
13+
14+ @ Override
15+ public Unit apply (Try <RouteResult > v1 ) {
16+ PekkoRouteHolder .restore ();
17+ return null ;
18+ }
19+ }
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