Skip to content

Commit 85ce47f

Browse files
committed
refactor: optimize ActionHandlerInstrumentation implementation
- Remove unused currentContext import - Change HandleAdvice class to private for better encapsulation - Refactor AdviceScope.start() to call Context.current() internally Change-Id: I69e0de219e8cc80bde3bedbd641a211b45ddd6f2
1 parent 2e9cf76 commit 85ce47f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

instrumentation/jfinal-3.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jfinal/v3_6/ActionHandlerInstrumentation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package io.opentelemetry.javaagent.instrumentation.jfinal.v3_6;
77

8-
import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
98
import static io.opentelemetry.javaagent.instrumentation.jfinal.v3_6.JFinalSingletons.instrumenter;
109
import static net.bytebuddy.matcher.ElementMatchers.named;
1110
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@@ -41,7 +40,7 @@ public void transform(TypeTransformer transformer) {
4140
}
4241

4342
@SuppressWarnings("unused")
44-
public static class HandleAdvice {
43+
private static class HandleAdvice {
4544

4645
public static class AdviceScope {
4746
private final Context context;
@@ -53,7 +52,8 @@ public AdviceScope(Context context, Scope scope) {
5352
}
5453

5554
@Nullable
56-
public static AdviceScope start(Context parentContext) {
55+
public static AdviceScope start() {
56+
Context parentContext = Context.current();
5757
if (!instrumenter().shouldStart(parentContext, null)) {
5858
return null;
5959
}
@@ -70,7 +70,7 @@ public void end(@Nullable Throwable throwable) {
7070

7171
@Advice.OnMethodEnter(suppress = Throwable.class)
7272
public static AdviceScope onEnter() {
73-
return AdviceScope.start(currentContext());
73+
return AdviceScope.start();
7474
}
7575

7676
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)

0 commit comments

Comments
 (0)