Better span names for rmi
MODIFY
instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/client/RmiClientInstrumentation.java
instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/client/RmiClientInstrumentation.java
@@ -25,7 +25,6 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
-import io.opentelemetry.auto.instrumentation.api.MoreTags;
import io.opentelemetry.auto.instrumentation.api.SpanWithScope;
import io.opentelemetry.auto.tooling.Instrumenter;
import io.opentelemetry.trace.Span;
@@ -69,8 +68,8 @@ public final class RmiClientInstrumentation extends Instrumenter.Default {
if (!TRACER.getCurrentSpan().getContext().isValid()) {
return null;
}
- final Span span = TRACER.spanBuilder("rmi.invoke").setSpanKind(CLIENT).startSpan();
- span.setAttribute(MoreTags.RESOURCE_NAME, DECORATE.spanNameForMethod(method));
+ final Span span =
+ TRACER.spanBuilder(DECORATE.spanNameForMethod(method)).setSpanKind(CLIENT).startSpan();
span.setAttribute("span.origin.type", method.getDeclaringClass().getCanonicalName());
DECORATE.afterStart(span);

MODIFY
instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/server/RmiServerInstrumentation.java
instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/server/RmiServerInstrumentation.java
@@ -29,7 +29,6 @@ import static net.bytebuddy.matcher.ElementMatchers.not;
import com.google.auto.service.AutoService;
import io.opentelemetry.auto.bootstrap.CallDepthThreadLocalMap;
-import io.opentelemetry.auto.instrumentation.api.MoreTags;
import io.opentelemetry.auto.instrumentation.api.SpanWithScope;
import io.opentelemetry.auto.tooling.Instrumenter;
import io.opentelemetry.trace.Span;
@@ -75,14 +74,14 @@ public final class RmiServerInstrumentation extends Instrumenter.Default {
}
final SpanContext context = THREAD_LOCAL_CONTEXT.getAndResetContext();
- final Span.Builder spanBuilder = TRACER.spanBuilder("rmi.request").setSpanKind(SERVER);
+ final Span.Builder spanBuilder =
+ TRACER.spanBuilder(DECORATE.spanNameForMethod(method)).setSpanKind(SERVER);
if (context != null) {
spanBuilder.setParent(context);
} else {
spanBuilder.setNoParent();
}
final Span span = spanBuilder.startSpan();
- span.setAttribute(MoreTags.RESOURCE_NAME, DECORATE.spanNameForMethod(method));
span.setAttribute("span.origin.type", thiz.getClass().getCanonicalName());
DECORATE.afterStart(span);

MODIFY
instrumentation/rmi/src/test/groovy/RmiTest.groovy
instrumentation/rmi/src/test/groovy/RmiTest.groovy
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import io.opentelemetry.auto.instrumentation.api.MoreTags
import io.opentelemetry.auto.instrumentation.api.Tags
import io.opentelemetry.auto.test.AgentTestRunner
import io.opentelemetry.auto.test.utils.PortUtils
@@ -55,20 +54,18 @@ class RmiTest extends AgentTestRunner {
trace(0, 3) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "rmi.invoke"
+ operationName "Greeter.hello"
spanKind CLIENT
childOf span(0)
tags {
- "$MoreTags.RESOURCE_NAME" "Greeter.hello"
"$Tags.COMPONENT" "rmi-client"
"span.origin.type" Greeter.canonicalName
}
}
span(2) {
- operationName "rmi.request"
+ operationName "Server.hello"
spanKind SERVER
tags {
- "$MoreTags.RESOURCE_NAME" "Server.hello"
"$Tags.COMPONENT" "rmi-server"
"span.origin.type" server.class.canonicalName
}
@@ -116,23 +113,21 @@ class RmiTest extends AgentTestRunner {
trace(0, 3) {
basicSpan(it, 0, "parent", null, null, thrownException)
span(1) {
- operationName "rmi.invoke"
+ operationName "Greeter.exceptional"
spanKind CLIENT
childOf span(0)
errored true
tags {
- "$MoreTags.RESOURCE_NAME" "Greeter.exceptional"
"$Tags.COMPONENT" "rmi-client"
"span.origin.type" Greeter.canonicalName
errorTags(RuntimeException, String)
}
}
span(2) {
- operationName "rmi.request"
+ operationName "Server.exceptional"
spanKind SERVER
errored true
tags {
- "$MoreTags.RESOURCE_NAME" "Server.exceptional"
"$Tags.COMPONENT" "rmi-server"
"span.origin.type" server.class.canonicalName
errorTags(RuntimeException, String)
@@ -162,21 +157,19 @@ class RmiTest extends AgentTestRunner {
trace(0, 3) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "rmi.invoke"
+ operationName "Greeter.hello"
spanKind CLIENT
childOf span(0)
tags {
- "$MoreTags.RESOURCE_NAME" "Greeter.hello"
"$Tags.COMPONENT" "rmi-client"
"span.origin.type" Greeter.canonicalName
}
}
span(2) {
childOf span(1)
- operationName "rmi.request"
+ operationName "ServerLegacy.hello"
spanKind SERVER
tags {
- "$MoreTags.RESOURCE_NAME" "ServerLegacy.hello"
"$Tags.COMPONENT" "rmi-server"
"span.origin.type" server.class.canonicalName
}

Better span names for rmi (#265)