Skip to content

Commit

Permalink
Develop/rmi instrumentation (#4764)
Browse files Browse the repository at this point in the history
* Remove new top level client span check from UnicastRefInstrumentation.java

* Instrument Remote instead of RemoteServer
  • Loading branch information
Samudraneel24 committed Dec 1, 2021
1 parent 8dab1ef commit 1ff51fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ public static void onEnter(

Context parentContext = Java8BytecodeBridge.currentContext();

// TODO replace with client span check - this is a bit different condition though, can we
// remove it?
if (!Java8BytecodeBridge.spanFromContext(parentContext).getSpanContext().isValid()) {
return;
}
if (!instrumenter().shouldStart(parentContext, method)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.rmi.server;

import static io.opentelemetry.javaagent.bootstrap.rmi.ThreadLocalContext.THREAD_LOCAL_CONTEXT;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.extendsClass;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.instrumentation.rmi.server.RmiServerSingletons.instrumenter;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
Expand All @@ -20,15 +20,15 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.api.CallDepth;
import java.rmi.server.RemoteServer;
import java.rmi.Remote;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

public class RemoteServerInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return extendsClass(named("java.rmi.server.RemoteServer"));
return implementsInterface(named("java.rmi.Remote"));
}

@Override
Expand All @@ -50,7 +50,7 @@ public static void onEnter(
@Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {

callDepth = CallDepth.forClass(RemoteServer.class);
callDepth = CallDepth.forClass(Remote.class);
if (callDepth.getAndIncrement() > 0) {
return;
}
Expand Down

0 comments on commit 1ff51fb

Please sign in to comment.