Better span names for jms
MODIFY
instrumentation/jms-1.1/src/latestDepTest/groovy/JMS2Test.groovy
instrumentation/jms-1.1/src/latestDepTest/groovy/JMS2Test.groovy
@@ -98,7 +98,7 @@ class JMS2Test extends AgentTestRunner {
server.stop()
}
- def "sending a message to #jmsResourceName generates spans"() {
+ def "sending a message to #expectedSpanName generates spans"() {
setup:
def producer = session.createProducer(destination)
def consumer = session.createConsumer(destination)
@@ -111,10 +111,10 @@ class JMS2Test extends AgentTestRunner {
receivedMessage.text == messageText
assertTraces(2) {
trace(0, 1) {
- producerSpan(it, 0, jmsResourceName)
+ producerSpan(it, 0, expectedSpanName)
}
trace(1, 1) {
- consumerSpan(it, 0, jmsResourceName, false, HornetQMessageConsumer, traces[0][0])
+ consumerSpan(it, 0, expectedSpanName, false, HornetQMessageConsumer, traces[0][0])
}
}
@@ -123,14 +123,14 @@ class JMS2Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
- session.createTemporaryQueue() | "Temporary Queue"
- session.createTemporaryTopic() | "Temporary Topic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
+ session.createTemporaryQueue() | "queue/<temporary>"
+ session.createTemporaryTopic() | "topic/<temporary>"
}
- def "sending to a MessageListener on #jmsResourceName generates a span"() {
+ def "sending to a MessageListener on #expectedSpanName generates a span"() {
setup:
def lock = new CountDownLatch(1)
def messageRef = new AtomicReference<TextMessage>()
@@ -150,8 +150,8 @@ class JMS2Test extends AgentTestRunner {
expect:
assertTraces(1) {
trace(0, 2) {
- producerSpan(it, 0, jmsResourceName)
- consumerSpan(it, 1, jmsResourceName, true, consumer.messageListener.class, span(0))
+ producerSpan(it, 0, expectedSpanName)
+ consumerSpan(it, 1, expectedSpanName, true, consumer.messageListener.class, span(0))
}
}
// This check needs to go after all traces have been accounted for
@@ -162,14 +162,14 @@ class JMS2Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
- session.createTemporaryQueue() | "Temporary Queue"
- session.createTemporaryTopic() | "Temporary Topic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
+ session.createTemporaryQueue() | "queue/<temporary>"
+ session.createTemporaryTopic() | "topic/<temporary>"
}
- def "failing to receive message with receiveNoWait on #jmsResourceName works"() {
+ def "failing to receive message with receiveNoWait on #expectedSpanName works"() {
setup:
def consumer = session.createConsumer(destination)
@@ -182,12 +182,11 @@ class JMS2Test extends AgentTestRunner {
trace(0, 1) { // Consumer trace
span(0) {
parent()
- operationName "jms.consume"
+ operationName "jms.receiveNoWait"
spanKind CLIENT
errored false
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" "JMS receiveNoWait"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_PRODUCER
"$Tags.COMPONENT" "jms"
"span.origin.type" HornetQMessageConsumer.name
@@ -200,12 +199,12 @@ class JMS2Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
}
- def "failing to receive message with wait(timeout) on #jmsResourceName works"() {
+ def "failing to receive message with wait(timeout) on #expectedSpanName works"() {
setup:
def consumer = session.createConsumer(destination)
@@ -218,12 +217,11 @@ class JMS2Test extends AgentTestRunner {
trace(0, 1) { // Consumer trace
span(0) {
parent()
- operationName "jms.consume"
+ operationName "jms.receive"
spanKind CLIENT
errored false
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" "JMS receive"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_PRODUCER
"$Tags.COMPONENT" "jms"
"span.origin.type" HornetQMessageConsumer.name
@@ -236,20 +234,19 @@ class JMS2Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
}
- static producerSpan(TraceAssert trace, int index, String jmsResourceName) {
+ static producerSpan(TraceAssert trace, int index, String expectedSpanName) {
trace.span(index) {
parent()
- operationName "jms.produce"
+ operationName expectedSpanName
spanKind PRODUCER
errored false
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" "Produced for $jmsResourceName"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_PRODUCER
"$Tags.COMPONENT" "jms"
"span.origin.type" HornetQMessageProducer.name
@@ -257,14 +254,13 @@ class JMS2Test extends AgentTestRunner {
}
}
- static consumerSpan(TraceAssert trace, int index, String jmsResourceName, boolean messageListener, Class origin, Object parentOrLinkSpan) {
+ static consumerSpan(TraceAssert trace, int index, String expectedSpanName, boolean messageListener, Class origin, Object parentOrLinkSpan) {
trace.span(index) {
+ operationName expectedSpanName
if (messageListener) {
- operationName "jms.onMessage"
spanKind CONSUMER
childOf((SpanData) parentOrLinkSpan)
} else {
- operationName "jms.consume"
spanKind CLIENT
parent()
hasLink((SpanData) parentOrLinkSpan)
@@ -273,7 +269,6 @@ class JMS2Test extends AgentTestRunner {
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" messageListener ? "Received from $jmsResourceName" : "Consumed from $jmsResourceName"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_CONSUMER
"$Tags.COMPONENT" "jms"
"span.origin.type" origin.name

MODIFY
instrumentation/jms-1.1/src/latestDepTest/groovy/SpringListenerJMS2Test.groovy
instrumentation/jms-1.1/src/latestDepTest/groovy/SpringListenerJMS2Test.groovy
@@ -37,11 +37,11 @@ class SpringListenerJMS2Test extends AgentTestRunner {
expect:
assertTraces(2) {
trace(0, 2) {
- producerSpan(it, 0, "Queue SpringListenerJMS2")
- consumerSpan(it, 1, "Queue SpringListenerJMS2", true, MessagingMessageListenerAdapter, span(0))
+ producerSpan(it, 0, "queue/SpringListenerJMS2")
+ consumerSpan(it, 1, "queue/SpringListenerJMS2", true, MessagingMessageListenerAdapter, span(0))
}
trace(1, 1) {
- consumerSpan(it, 0, "Queue SpringListenerJMS2", false, HornetQMessageConsumer, traces[0][0])
+ consumerSpan(it, 0, "queue/SpringListenerJMS2", false, HornetQMessageConsumer, traces[0][0])
}
}
}

MODIFY
instrumentation/jms-1.1/src/latestDepTest/groovy/SpringTemplateJMS2Test.groovy
instrumentation/jms-1.1/src/latestDepTest/groovy/SpringTemplateJMS2Test.groovy
@@ -99,16 +99,16 @@ class SpringTemplateJMS2Test extends AgentTestRunner {
receivedMessage.text == messageText
assertTraces(2) {
trace(0, 1) {
- producerSpan(it, 0, jmsResourceName)
+ producerSpan(it, 0, expectedSpanName)
}
trace(1, 1) {
- consumerSpan(it, 0, jmsResourceName, false, HornetQMessageConsumer, traces[0][0])
+ consumerSpan(it, 0, expectedSpanName, false, HornetQMessageConsumer, traces[0][0])
}
}
where:
- destination | jmsResourceName
- session.createQueue("SpringTemplateJMS2") | "Queue SpringTemplateJMS2"
+ destination | expectedSpanName
+ session.createQueue("SpringTemplateJMS2") | "queue/SpringTemplateJMS2"
}
def "send and receive message generates spans"() {
@@ -130,21 +130,21 @@ class SpringTemplateJMS2Test extends AgentTestRunner {
receivedMessage.text == "responded!"
assertTraces(4) {
trace(0, 1) {
- producerSpan(it, 0, jmsResourceName)
+ producerSpan(it, 0, expectedSpanName)
}
trace(1, 1) {
- consumerSpan(it, 0, jmsResourceName, false, HornetQMessageConsumer, traces[0][0])
+ consumerSpan(it, 0, expectedSpanName, false, HornetQMessageConsumer, traces[0][0])
}
trace(2, 1) {
- producerSpan(it, 0, "Temporary Queue") // receive doesn't propagate the trace, so this is a root
+ producerSpan(it, 0, "queue/<temporary>") // receive doesn't propagate the trace, so this is a root
}
trace(3, 1) {
- consumerSpan(it, 0, "Temporary Queue", false, HornetQMessageConsumer, traces[2][0])
+ consumerSpan(it, 0, "queue/<temporary>", false, HornetQMessageConsumer, traces[2][0])
}
}
where:
- destination | jmsResourceName
- session.createQueue("SpringTemplateJMS2") | "Queue SpringTemplateJMS2"
+ destination | expectedSpanName
+ session.createQueue("SpringTemplateJMS2") | "queue/SpringTemplateJMS2"
}
}

MODIFY
instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSDecorator.java
instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSDecorator.java
@@ -17,9 +17,7 @@ package io.opentelemetry.auto.instrumentation.jms;
import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.auto.bootstrap.instrumentation.decorator.ClientDecorator;
-import io.opentelemetry.auto.instrumentation.api.MoreTags;
import io.opentelemetry.auto.instrumentation.api.SpanTypes;
-import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.Tracer;
import java.lang.reflect.Method;
import javax.jms.Destination;
@@ -59,21 +57,20 @@ public abstract class JMSDecorator extends ClientDecorator {
return "jms";
}
- public void onConsume(final Span span, final Message message) {
- span.setAttribute(MoreTags.RESOURCE_NAME, "Consumed from " + toResourceName(message, null));
+ public String spanNameForReceive(final Message message) {
+ return toResourceName(message, null);
}
- public void onReceive(final Span span, final Method method) {
- span.setAttribute(MoreTags.RESOURCE_NAME, "JMS " + method.getName());
+ public String spanNameForReceive(final Method method) {
+ return "jms." + method.getName();
}
- public void onReceive(final Span span, final Message message) {
- span.setAttribute(MoreTags.RESOURCE_NAME, "Received from " + toResourceName(message, null));
+ public String spanNameForConsumer(final Message message) {
+ return toResourceName(message, null);
}
- public void onProduce(final Span span, final Message message, final Destination destination) {
- span.setAttribute(
- MoreTags.RESOURCE_NAME, "Produced for " + toResourceName(message, destination));
+ public String spanNameForProducer(final Message message, final Destination destination) {
+ return toResourceName(message, destination);
}
private static final String TIBCO_TMP_PREFIX = "$TMP$";
@@ -91,21 +88,21 @@ public abstract class JMSDecorator extends ClientDecorator {
if (jmsDestination instanceof Queue) {
final String queueName = ((Queue) jmsDestination).getQueueName();
if (jmsDestination instanceof TemporaryQueue || queueName.startsWith(TIBCO_TMP_PREFIX)) {
- return "Temporary Queue";
+ return "queue/<temporary>";
} else {
- return "Queue " + queueName;
+ return "queue/" + queueName;
}
}
if (jmsDestination instanceof Topic) {
final String topicName = ((Topic) jmsDestination).getTopicName();
if (jmsDestination instanceof TemporaryTopic || topicName.startsWith(TIBCO_TMP_PREFIX)) {
- return "Temporary Topic";
+ return "topic/<temporary>";
} else {
- return "Topic " + topicName;
+ return "topic/" + topicName;
}
}
} catch (final Exception e) {
}
- return "Destination";
+ return "destination";
}
}

MODIFY
instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageConsumerInstrumentation.java
instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageConsumerInstrumentation.java
@@ -96,9 +96,15 @@ public final class JMSMessageConsumerInstrumentation extends Instrumenter.Defaul
@Advice.Origin final Method method,
@Advice.Return final Message message,
@Advice.Thrown final Throwable throwable) {
+ final String spanName;
+ if (message == null) {
+ spanName = CONSUMER_DECORATE.spanNameForReceive(method);
+ } else {
+ spanName = CONSUMER_DECORATE.spanNameForReceive(message);
+ }
final Span.Builder spanBuilder =
TRACER
- .spanBuilder("jms.consume")
+ .spanBuilder(spanName)
.setSpanKind(CLIENT)
.setStartTimestamp(TimeUnit.MILLISECONDS.toNanos(startTime));
if (message != null) {
@@ -117,11 +123,6 @@ public final class JMSMessageConsumerInstrumentation extends Instrumenter.Defaul
try (final Scope scope = TRACER.withSpan(span)) {
CONSUMER_DECORATE.afterStart(span);
- if (message == null) {
- CONSUMER_DECORATE.onReceive(span, method);
- } else {
- CONSUMER_DECORATE.onConsume(span, message);
- }
CONSUMER_DECORATE.onError(span, throwable);
CONSUMER_DECORATE.beforeFinish(span);
span.end();

MODIFY
instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageListenerInstrumentation.java
instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageListenerInstrumentation.java
@@ -81,7 +81,8 @@ public final class JMSMessageListenerInstrumentation extends Instrumenter.Defaul
public static SpanWithScope onEnter(
@Advice.Argument(0) final Message message, @Advice.This final MessageListener listener) {
- final Span.Builder spanBuilder = TRACER.spanBuilder("jms.onMessage").setSpanKind(CONSUMER);
+ final Span.Builder spanBuilder =
+ TRACER.spanBuilder(CONSUMER_DECORATE.spanNameForConsumer(message)).setSpanKind(CONSUMER);
try {
final SpanContext extractedContext = TRACER.getHttpTextFormat().extract(message, GETTER);
spanBuilder.setParent(extractedContext);
@@ -93,7 +94,6 @@ public final class JMSMessageListenerInstrumentation extends Instrumenter.Defaul
final Span span = spanBuilder.startSpan();
span.setAttribute("span.origin.type", listener.getClass().getName());
CONSUMER_DECORATE.afterStart(span);
- CONSUMER_DECORATE.onReceive(span, message);
return new SpanWithScope(span, TRACER.withSpan(span));
}

MODIFY
instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageProducerInstrumentation.java
instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageProducerInstrumentation.java
@@ -102,10 +102,13 @@ public final class JMSMessageProducerInstrumentation extends Instrumenter.Defaul
defaultDestination = null;
}
- final Span span = TRACER.spanBuilder("jms.produce").setSpanKind(PRODUCER).startSpan();
+ final Span span =
+ TRACER
+ .spanBuilder(PRODUCER_DECORATE.spanNameForProducer(message, defaultDestination))
+ .setSpanKind(PRODUCER)
+ .startSpan();
span.setAttribute("span.origin.type", producer.getClass().getName());
PRODUCER_DECORATE.afterStart(span);
- PRODUCER_DECORATE.onProduce(span, message, defaultDestination);
TRACER.getHttpTextFormat().inject(span.getContext(), message, SETTER);
@@ -141,10 +144,13 @@ public final class JMSMessageProducerInstrumentation extends Instrumenter.Defaul
return null;
}
- final Span span = TRACER.spanBuilder("jms.produce").setSpanKind(PRODUCER).startSpan();
+ final Span span =
+ TRACER
+ .spanBuilder(PRODUCER_DECORATE.spanNameForProducer(message, destination))
+ .setSpanKind(PRODUCER)
+ .startSpan();
span.setAttribute("span.origin.type", producer.getClass().getName());
PRODUCER_DECORATE.afterStart(span);
- PRODUCER_DECORATE.onProduce(span, message, destination);
TRACER.getHttpTextFormat().inject(span.getContext(), message, SETTER);

MODIFY
instrumentation/jms-1.1/src/test/groovy/JMS1Test.groovy
instrumentation/jms-1.1/src/test/groovy/JMS1Test.groovy
@@ -61,7 +61,7 @@ class JMS1Test extends AgentTestRunner {
broker.stop()
}
- def "sending a message to #jmsResourceName generates spans"() {
+ def "sending a message to #expectedSpanName generates spans"() {
setup:
def producer = session.createProducer(destination)
def consumer = session.createConsumer(destination)
@@ -74,10 +74,10 @@ class JMS1Test extends AgentTestRunner {
receivedMessage.text == messageText
assertTraces(2) {
trace(0, 1) {
- producerSpan(it, 0, jmsResourceName)
+ producerSpan(it, 0, expectedSpanName)
}
trace(1, 1) {
- consumerSpan(it, 0, jmsResourceName, false, ActiveMQMessageConsumer, traces[0][0])
+ consumerSpan(it, 0, expectedSpanName, false, ActiveMQMessageConsumer, traces[0][0])
}
}
@@ -86,14 +86,14 @@ class JMS1Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
- session.createTemporaryQueue() | "Temporary Queue"
- session.createTemporaryTopic() | "Temporary Topic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
+ session.createTemporaryQueue() | "queue/<temporary>"
+ session.createTemporaryTopic() | "topic/<temporary>"
}
- def "sending to a MessageListener on #jmsResourceName generates a span"() {
+ def "sending to a MessageListener on #expectedSpanName generates a span"() {
setup:
def lock = new CountDownLatch(1)
def messageRef = new AtomicReference<TextMessage>()
@@ -113,8 +113,8 @@ class JMS1Test extends AgentTestRunner {
expect:
assertTraces(1) {
trace(0, 2) {
- producerSpan(it, 0, jmsResourceName)
- consumerSpan(it, 1, jmsResourceName, true, consumer.messageListener.class, span(0))
+ producerSpan(it, 0, expectedSpanName)
+ consumerSpan(it, 1, expectedSpanName, true, consumer.messageListener.class, span(0))
}
}
// This check needs to go after all traces have been accounted for
@@ -125,14 +125,14 @@ class JMS1Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
- session.createTemporaryQueue() | "Temporary Queue"
- session.createTemporaryTopic() | "Temporary Topic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
+ session.createTemporaryQueue() | "queue/<temporary>"
+ session.createTemporaryTopic() | "topic/<temporary>"
}
- def "failing to receive message with receiveNoWait on #jmsResourceName works"() {
+ def "failing to receive message with receiveNoWait on #expectedSpanName works"() {
setup:
def consumer = session.createConsumer(destination)
@@ -145,12 +145,11 @@ class JMS1Test extends AgentTestRunner {
trace(0, 1) { // Consumer trace
span(0) {
parent()
- operationName "jms.consume"
+ operationName "jms.receiveNoWait"
spanKind CLIENT
errored false
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" "JMS receiveNoWait"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_CONSUMER
"$Tags.COMPONENT" "jms"
"span.origin.type" ActiveMQMessageConsumer.name
@@ -163,12 +162,12 @@ class JMS1Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
}
- def "failing to receive message with wait(timeout) on #jmsResourceName works"() {
+ def "failing to receive message with wait(timeout) on #expectedSpanName works"() {
setup:
def consumer = session.createConsumer(destination)
@@ -181,12 +180,11 @@ class JMS1Test extends AgentTestRunner {
trace(0, 1) { // Consumer trace
span(0) {
parent()
- operationName "jms.consume"
+ operationName "jms.receive"
spanKind CLIENT
errored false
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" "JMS receive"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_CONSUMER
"$Tags.COMPONENT" "jms"
"span.origin.type" ActiveMQMessageConsumer.name
@@ -199,12 +197,12 @@ class JMS1Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
}
- def "sending a read-only message to #jmsResourceName fails"() {
+ def "sending a read-only message to #expectedSpanName fails"() {
setup:
def producer = session.createProducer(destination)
def consumer = session.createConsumer(destination)
@@ -227,17 +225,16 @@ class JMS1Test extends AgentTestRunner {
// The consumer span will also not be linked to the parent.
assertTraces(2) {
trace(0, 1) {
- producerSpan(it, 0, jmsResourceName)
+ producerSpan(it, 0, expectedSpanName)
}
trace(1, 1) {
span(0) {
parent()
- operationName "jms.consume"
+ operationName expectedSpanName
spanKind CLIENT
errored false
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" "Consumed from $jmsResourceName"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_CONSUMER
"$Tags.COMPONENT" "jms"
"span.origin.type" ActiveMQMessageConsumer.name
@@ -251,22 +248,21 @@ class JMS1Test extends AgentTestRunner {
consumer.close()
where:
- destination | jmsResourceName
- session.createQueue("someQueue") | "Queue someQueue"
- session.createTopic("someTopic") | "Topic someTopic"
- session.createTemporaryQueue() | "Temporary Queue"
- session.createTemporaryTopic() | "Temporary Topic"
+ destination | expectedSpanName
+ session.createQueue("someQueue") | "queue/someQueue"
+ session.createTopic("someTopic") | "topic/someTopic"
+ session.createTemporaryQueue() | "queue/<temporary>"
+ session.createTemporaryTopic() | "topic/<temporary>"
}
- static producerSpan(TraceAssert trace, int index, String jmsResourceName) {
+ static producerSpan(TraceAssert trace, int index, String expectedSpanName) {
trace.span(index) {
- operationName "jms.produce"
+ operationName expectedSpanName
spanKind PRODUCER
errored false
parent()
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" "Produced for $jmsResourceName"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_PRODUCER
"$Tags.COMPONENT" "jms"
"span.origin.type" ActiveMQMessageProducer.name
@@ -274,14 +270,13 @@ class JMS1Test extends AgentTestRunner {
}
}
- static consumerSpan(TraceAssert trace, int index, String jmsResourceName, boolean messageListener, Class origin, Object parentOrLinkedSpan) {
+ static consumerSpan(TraceAssert trace, int index, String expectedSpanName, boolean messageListener, Class origin, Object parentOrLinkedSpan) {
trace.span(index) {
+ operationName expectedSpanName
if (messageListener) {
- operationName "jms.onMessage"
spanKind CONSUMER
childOf((SpanData) parentOrLinkedSpan)
} else {
- operationName "jms.consume"
spanKind CLIENT
parent()
hasLink((SpanData) parentOrLinkedSpan)
@@ -289,7 +284,6 @@ class JMS1Test extends AgentTestRunner {
errored false
tags {
"$MoreTags.SERVICE_NAME" "jms"
- "$MoreTags.RESOURCE_NAME" messageListener ? "Received from $jmsResourceName" : "Consumed from $jmsResourceName"
"$MoreTags.SPAN_TYPE" SpanTypes.MESSAGE_CONSUMER
"$Tags.COMPONENT" "jms"
"span.origin.type" origin.name

MODIFY
instrumentation/jms-1.1/src/test/groovy/SpringListenerJMS1Test.groovy
instrumentation/jms-1.1/src/test/groovy/SpringListenerJMS1Test.groovy
@@ -38,11 +38,11 @@ class SpringListenerJMS1Test extends AgentTestRunner {
expect:
assertTraces(2) {
trace(0, 2) {
- producerSpan(it, 0, "Queue SpringListenerJMS1")
- consumerSpan(it, 1, "Queue SpringListenerJMS1", true, MessagingMessageListenerAdapter, span(0))
+ producerSpan(it, 0, "queue/SpringListenerJMS1")
+ consumerSpan(it, 1, "queue/SpringListenerJMS1", true, MessagingMessageListenerAdapter, span(0))
}
trace(1, 1) {
- consumerSpan(it, 0, "Queue SpringListenerJMS1", false, ActiveMQMessageConsumer, traces[0][0])
+ consumerSpan(it, 0, "queue/SpringListenerJMS1", false, ActiveMQMessageConsumer, traces[0][0])
}
}

MODIFY
instrumentation/jms-1.1/src/test/groovy/SpringTemplateJMS1Test.groovy
instrumentation/jms-1.1/src/test/groovy/SpringTemplateJMS1Test.groovy
@@ -67,16 +67,16 @@ class SpringTemplateJMS1Test extends AgentTestRunner {
receivedMessage.text == messageText
assertTraces(2) {
trace(0, 1) {
- producerSpan(it, 0, jmsResourceName)
+ producerSpan(it, 0, expectedSpanName)
}
trace(1, 1) {
- consumerSpan(it, 0, jmsResourceName, false, ActiveMQMessageConsumer, traces[0][0])
+ consumerSpan(it, 0, expectedSpanName, false, ActiveMQMessageConsumer, traces[0][0])
}
}
where:
- destination | jmsResourceName
- session.createQueue("SpringTemplateJMS1") | "Queue SpringTemplateJMS1"
+ destination | expectedSpanName
+ session.createQueue("SpringTemplateJMS1") | "queue/SpringTemplateJMS1"
}
def "send and receive message generates spans"() {
@@ -102,21 +102,21 @@ class SpringTemplateJMS1Test extends AgentTestRunner {
receivedMessage.text == "responded!"
assertTraces(4) {
trace(0, 1) {
- producerSpan(it, 0, jmsResourceName)
+ producerSpan(it, 0, expectedSpanName)
}
trace(1, 1) {
- consumerSpan(it, 0, jmsResourceName, false, ActiveMQMessageConsumer, traces[0][0])
+ consumerSpan(it, 0, expectedSpanName, false, ActiveMQMessageConsumer, traces[0][0])
}
trace(2, 1) {
- producerSpan(it, 0, "Temporary Queue") // receive doesn't propagate the trace, so this is a root
+ producerSpan(it, 0, "queue/<temporary>") // receive doesn't propagate the trace, so this is a root
}
trace(3, 1) {
- consumerSpan(it, 0, "Temporary Queue", false, ActiveMQMessageConsumer, traces[2][0])
+ consumerSpan(it, 0, "queue/<temporary>", false, ActiveMQMessageConsumer, traces[2][0])
}
}
where:
- destination | jmsResourceName
- session.createQueue("SpringTemplateJMS1") | "Queue SpringTemplateJMS1"
+ destination | expectedSpanName
+ session.createQueue("SpringTemplateJMS1") | "queue/SpringTemplateJMS1"
}
}

Better span names for jms (#240)