Commit 946babb 1 parent ea4aa39 commit 946babb Copy full SHA for 946babb
File tree 4 files changed +66
-9
lines changed
akka/akka-actor-2.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkaactor
pekko/pekko-actor-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkoactor/v1_0
4 files changed +66
-9
lines changed Original file line number Diff line number Diff line change 8
8
import static net .bytebuddy .matcher .ElementMatchers .named ;
9
9
import static net .bytebuddy .matcher .ElementMatchers .takesArgument ;
10
10
11
- import io .opentelemetry .context .Context ;
12
- import io .opentelemetry .javaagent .bootstrap .Java8BytecodeBridge ;
13
11
import io .opentelemetry .javaagent .extension .instrumentation .TypeInstrumentation ;
14
12
import io .opentelemetry .javaagent .extension .instrumentation .TypeTransformer ;
15
13
import net .bytebuddy .asm .Advice ;
@@ -46,8 +44,7 @@ public static class ScheduleAdvice {
46
44
@ Advice .OnMethodEnter (suppress = Throwable .class )
47
45
public static void enterSchedule (
48
46
@ Advice .Argument (value = 2 , readOnly = false ) Runnable runnable ) {
49
- Context context = Java8BytecodeBridge .currentContext ();
50
- runnable = context .wrap (runnable );
47
+ runnable = AkkaSchedulerTaskWrapper .wrap (runnable );
51
48
}
52
49
}
53
50
@@ -57,8 +54,7 @@ public static class ScheduleOnceAdvice {
57
54
@ Advice .OnMethodEnter (suppress = Throwable .class )
58
55
public static void enterScheduleOnce (
59
56
@ Advice .Argument (value = 1 , readOnly = false ) Runnable runnable ) {
60
- Context context = Java8BytecodeBridge .currentContext ();
61
- runnable = context .wrap (runnable );
57
+ runnable = AkkaSchedulerTaskWrapper .wrap (runnable );
62
58
}
63
59
}
64
60
}
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 .akkaactor ;
7
+
8
+ import io .opentelemetry .context .Context ;
9
+
10
+ public final class AkkaSchedulerTaskWrapper {
11
+ private static final Class <?> RUN_ON_CLOSE_TASK_CLASS = getRunOnCloseTaskClass ();
12
+
13
+ private static Class <?> getRunOnCloseTaskClass () {
14
+ try {
15
+ return Class .forName ("akka.actor.Scheduler$TaskRunOnClose" );
16
+ } catch (ClassNotFoundException e ) {
17
+ return null ;
18
+ }
19
+ }
20
+
21
+ private static boolean isRunOnCloseTask (Runnable runnable ) {
22
+ return RUN_ON_CLOSE_TASK_CLASS != null && RUN_ON_CLOSE_TASK_CLASS .isInstance (runnable );
23
+ }
24
+
25
+ public static Runnable wrap (Runnable runnable ) {
26
+ // https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/13066
27
+ // Skip wrapping shutdown tasks. Shutdown process hangs when shutdown tasks are wrapped here.
28
+ if (isRunOnCloseTask (runnable )) {
29
+ return runnable ;
30
+ }
31
+
32
+ Context context = Context .current ();
33
+ return context .wrap (runnable );
34
+ }
35
+
36
+ private AkkaSchedulerTaskWrapper () {}
37
+ }
Original file line number Diff line number Diff line change 8
8
import static net .bytebuddy .matcher .ElementMatchers .named ;
9
9
import static net .bytebuddy .matcher .ElementMatchers .takesArgument ;
10
10
11
- import io .opentelemetry .javaagent .bootstrap .Java8BytecodeBridge ;
12
11
import io .opentelemetry .javaagent .extension .instrumentation .TypeInstrumentation ;
13
12
import io .opentelemetry .javaagent .extension .instrumentation .TypeTransformer ;
14
13
import net .bytebuddy .asm .Advice ;
@@ -46,7 +45,7 @@ public static class ScheduleAdvice {
46
45
@ Advice .AssignReturned .ToArguments (@ ToArgument (2 ))
47
46
@ Advice .OnMethodEnter (suppress = Throwable .class )
48
47
public static Runnable enterSchedule (@ Advice .Argument (value = 2 ) Runnable runnable ) {
49
- return Java8BytecodeBridge . currentContext () .wrap (runnable );
48
+ return PekkoSchedulerTaskWrapper .wrap (runnable );
50
49
}
51
50
}
52
51
@@ -56,7 +55,7 @@ public static class ScheduleOnceAdvice {
56
55
@ Advice .AssignReturned .ToArguments (@ ToArgument (1 ))
57
56
@ Advice .OnMethodEnter (suppress = Throwable .class )
58
57
public static Runnable enterScheduleOnce (@ Advice .Argument (value = 1 ) Runnable runnable ) {
59
- return Java8BytecodeBridge . currentContext () .wrap (runnable );
58
+ return PekkoSchedulerTaskWrapper .wrap (runnable );
60
59
}
61
60
}
62
61
}
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 .pekkoactor .v1_0 ;
7
+
8
+ import io .opentelemetry .context .Context ;
9
+ import org .apache .pekko .actor .Scheduler ;
10
+
11
+ public final class PekkoSchedulerTaskWrapper {
12
+
13
+ public static Runnable wrap (Runnable runnable ) {
14
+ // https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/13066
15
+ // Skip wrapping shutdown tasks. Shutdown process hangs when shutdown tasks are wrapped here.
16
+ if (runnable instanceof Scheduler .TaskRunOnClose ) {
17
+ return runnable ;
18
+ }
19
+
20
+ Context context = Context .current ();
21
+ return context .wrap (runnable );
22
+ }
23
+
24
+ private PekkoSchedulerTaskWrapper () {}
25
+ }
You can’t perform that action at this time.
0 commit comments