Skip to content

Commit 0e3e14a

Browse files
committed
post-review change, static enter method
1 parent ac009e6 commit 0e3e14a

File tree

1 file changed

+14
-12
lines changed
  • instrumentation/spring/spring-rmi-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/rmi/v4_0/server

1 file changed

+14
-12
lines changed

instrumentation/spring/spring-rmi-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/rmi/v4_0/server/ServerInstrumentation.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,31 @@ public static class AdviceScope {
4949
private final Context context;
5050
private final Scope scope;
5151

52-
public AdviceScope(
53-
CallDepth callDepth, RmiBasedExporter rmiExporter, RemoteInvocation remoteInvocation) {
52+
private AdviceScope(
53+
CallDepth callDepth, ClassAndMethod request, Context context, Scope scope) {
5454
this.callDepth = callDepth;
55+
this.request = request;
56+
this.context = context;
57+
this.scope = scope;
58+
}
59+
60+
public static AdviceScope enter(
61+
CallDepth callDepth, RmiBasedExporter rmiExporter, RemoteInvocation remoteInvocation) {
5562
if (callDepth.getAndIncrement() > 0) {
56-
this.request = null;
57-
this.context = null;
58-
this.scope = null;
59-
return;
63+
return new AdviceScope(callDepth, null, null, null);
6064
}
6165

6266
Context parentContext = THREAD_LOCAL_CONTEXT.getAndResetContext();
6367
Class<?> serverClass = rmiExporter.getService().getClass();
6468
String methodName = remoteInvocation.getMethodName();
65-
request = ClassAndMethod.create(serverClass, methodName);
69+
ClassAndMethod request = ClassAndMethod.create(serverClass, methodName);
6670

6771
if (!serverInstrumenter().shouldStart(parentContext, request)) {
68-
context = null;
69-
scope = null;
70-
return;
72+
return new AdviceScope(callDepth, request, null, null);
7173
}
7274

73-
context = serverInstrumenter().start(parentContext, request);
74-
scope = context.makeCurrent();
75+
Context context = serverInstrumenter().start(parentContext, request);
76+
return new AdviceScope(callDepth, request, context, context.makeCurrent());
7577
}
7678

7779
public void exit(@Nullable Throwable throwable) {

0 commit comments

Comments
 (0)