Better span names for trace-annotation
MODIFY
instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/traceannotation/TraceAdvice.java
instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/traceannotation/TraceAdvice.java
@@ -18,7 +18,6 @@ package io.opentelemetry.auto.instrumentation.traceannotation;
import static io.opentelemetry.auto.instrumentation.traceannotation.TraceDecorator.DECORATE;
import static io.opentelemetry.auto.instrumentation.traceannotation.TraceDecorator.TRACER;
-import io.opentelemetry.auto.instrumentation.api.MoreTags;
import io.opentelemetry.auto.instrumentation.api.SpanWithScope;
import io.opentelemetry.trace.Span;
import java.lang.reflect.Method;
@@ -28,9 +27,7 @@ public class TraceAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static SpanWithScope onEnter(@Advice.Origin final Method method) {
- final Span span = TRACER.spanBuilder("trace.annotation").startSpan();
- final String resourceName = DECORATE.spanNameForMethod(method);
- span.setAttribute(MoreTags.RESOURCE_NAME, resourceName);
+ final Span span = TRACER.spanBuilder(DECORATE.spanNameForMethod(method)).startSpan();
DECORATE.afterStart(span);
return new SpanWithScope(span, TRACER.withSpan(span));
}

MODIFY
instrumentation/trace-annotation/src/test/groovy/ConfiguredTraceAnnotationsTest.groovy
instrumentation/trace-annotation/src/test/groovy/ConfiguredTraceAnnotationsTest.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.instrumentation.traceannotation.TraceAnnotationsInstrumentation
import io.opentelemetry.auto.test.AgentTestRunner
@@ -52,9 +51,8 @@ class ConfiguredTraceAnnotationsTest extends AgentTestRunner {
assertTraces(1) {
trace(0, 1) {
span(0) {
- operationName "trace.annotation"
+ operationName "AnnotationTracedCallable.call"
tags {
- "$MoreTags.RESOURCE_NAME" "AnnotationTracedCallable.call"
"$Tags.COMPONENT" "trace"
}
}

MODIFY
instrumentation/trace-annotation/src/test/groovy/TraceAnnotationsTest.groovy
instrumentation/trace-annotation/src/test/groovy/TraceAnnotationsTest.groovy
@@ -39,12 +39,11 @@ class TraceAnnotationsTest extends AgentTestRunner {
assertTraces(1) {
trace(0, 1) {
span(0) {
- operationName "trace.annotation"
+ operationName "SayTracedHello.sayHello"
parent()
errored false
tags {
"$MoreTags.SERVICE_NAME" "test"
- "$MoreTags.RESOURCE_NAME" "SayTracedHello.sayHello"
"$Tags.COMPONENT" "trace"
}
}
@@ -61,32 +60,29 @@ class TraceAnnotationsTest extends AgentTestRunner {
assertTraces(1) {
trace(0, 3) {
span(0) {
- operationName "trace.annotation"
+ operationName "SayTracedHello.sayHELLOsayHA"
parent()
errored false
tags {
"$MoreTags.SERVICE_NAME" "test2"
- "$MoreTags.RESOURCE_NAME" "SayTracedHello.sayHELLOsayHA"
"$Tags.COMPONENT" "trace"
}
}
span(1) {
- operationName "trace.annotation"
+ operationName "SayTracedHello.sayHello"
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" "test"
- "$MoreTags.RESOURCE_NAME" "SayTracedHello.sayHello"
"$Tags.COMPONENT" "trace"
}
}
span(2) {
- operationName "trace.annotation"
+ operationName "SayTracedHello.sayHello"
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" "test"
- "$MoreTags.RESOURCE_NAME" "SayTracedHello.sayHello"
"$Tags.COMPONENT" "trace"
}
}
@@ -108,10 +104,9 @@ class TraceAnnotationsTest extends AgentTestRunner {
assertTraces(1) {
trace(0, 1) {
span(0) {
- operationName "trace.annotation"
+ operationName "SayTracedHello.sayERROR"
errored true
tags {
- "$MoreTags.RESOURCE_NAME" "SayTracedHello.sayERROR"
"$Tags.COMPONENT" "trace"
errorTags(error.class)
}
@@ -129,9 +124,8 @@ class TraceAnnotationsTest extends AgentTestRunner {
assertTraces(1) {
trace(0, 1) {
span(0) {
- operationName "trace.annotation"
+ operationName "SayTracedHello\$1.call"
tags {
- "$MoreTags.RESOURCE_NAME" "SayTracedHello\$1.call"
"$Tags.COMPONENT" "trace"
}
}
@@ -152,17 +146,15 @@ class TraceAnnotationsTest extends AgentTestRunner {
assertTraces(2) {
trace(0, 1) {
span(0) {
- operationName "trace.annotation"
+ operationName "SayTracedHello\$1.call"
tags {
- "$MoreTags.RESOURCE_NAME" "SayTracedHello\$1.call"
"$Tags.COMPONENT" "trace"
}
}
trace(1, 1) {
span(0) {
- operationName "trace.annotation"
+ operationName "TraceAnnotationsTest\$1.call"
tags {
- "$MoreTags.RESOURCE_NAME" "TraceAnnotationsTest\$1.call"
"$Tags.COMPONENT" "trace"
}
}

MODIFY
instrumentation/trace-annotation/src/test/groovy/TraceConfigTest.groovy
instrumentation/trace-annotation/src/test/groovy/TraceConfigTest.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.instrumentation.traceannotation.TraceConfigInstrumentation
import io.opentelemetry.auto.test.AgentTestRunner
@@ -50,9 +49,8 @@ class TraceConfigTest extends AgentTestRunner {
assertTraces(1) {
trace(0, 1) {
span(0) {
- operationName "trace.annotation"
+ operationName "ConfigTracedCallable.call"
tags {
- "$MoreTags.RESOURCE_NAME" "ConfigTracedCallable.call"
"$Tags.COMPONENT" "trace"
}
}

Better span names for trace-annotation (#260)