JmsTracing { public MessageListener messageListener(MessageListener messageListener, boolean addConsumerSpan) { if (messageListener instanceof TracingMessageListener) return messageListener; return new TracingMessageListener(messageListener, this, addConsumerSpan); } JmsTracing(Builder builder); static JmsTracing create(Tracing tracing); static JmsTracing create(MessagingTracing messagingTracing); static Builder newBuilder(Tracing tracing); static Builder newBuilder(MessagingTracing messagingTracing); Connection connection(Connection connection); QueueConnection queueConnection(QueueConnection connection); TopicConnection topicConnection(TopicConnection connection); XAConnection xaConnection(XAConnection xaConnection); XAQueueConnection xaQueueConnection(XAQueueConnection connection); XATopicConnection xaTopicConnection(XATopicConnection connection); ConnectionFactory connectionFactory(ConnectionFactory connectionFactory); XAConnectionFactory xaConnectionFactory(XAConnectionFactory xaConnectionFactory); MessageListener messageListener(MessageListener messageListener, boolean addConsumerSpan); Span nextSpan(Message message);  }
@Test public void messageListener_traces() { jmsTracing.messageListener(mock(MessageListener.class), false) .onMessage(message); assertThat(testSpanHandler.takeLocalSpan().name()).isEqualTo("on-message"); }
@Test public void messageListener_traces_addsConsumerSpan() { jmsTracing.messageListener(mock(MessageListener.class), true) .onMessage(message); assertThat(asList(testSpanHandler.takeRemoteSpan(Kind.CONSUMER), testSpanHandler.takeLocalSpan())) .extracting(brave.handler.MutableSpan::name) .containsExactly("receive", "on-message"); }
@Test public void messageListener_wrapsInput() { assertThat(jmsTracing.messageListener(mock(MessageListener.class), false)) .isInstanceOf(TracingMessageListener.class); }
@Test public void messageListener_doesntDoubleWrap() { MessageListener wrapped = jmsTracing.messageListener(mock(MessageListener.class), false); assertThat(jmsTracing.messageListener(wrapped, false)) .isSameAs(wrapped); }