TracingJMSConsumer extends TracingConsumer<JMSConsumer> implements JMSConsumer { @Override public Message receive() { Message message = delegate.receive(); handleReceive(message); return message; } TracingJMSConsumer(JMSConsumer delegate, Destination destination, JmsTracing jmsTracing); @Override String getMessageSelector(); @Override MessageListener getMessageListener(); @Override void setMessageListener(MessageListener listener); @Override Message receive(); @Override Message receive(long timeout); @Override Message receiveNoWait(); @Override void close(); @Override T receiveBody(Class<T> c); @Override T receiveBody(Class<T> c, long timeout); @Override T receiveBodyNoWait(Class<T> c);  }
@Test public void receive_creates_consumer_span() throws Exception { ActiveMQTextMessage message = new ActiveMQTextMessage(); receive(message); MutableSpan consumer = testSpanHandler.takeRemoteSpan(CONSUMER); assertThat(consumer.name()).isEqualTo("receive"); assertThat(consumer.name()).isEqualTo("receive"); }
@Test public void receive_continues_parent_trace_single_header() throws Exception { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setStringProperty("b3", B3SingleFormat.writeB3SingleFormatWithoutParentId(parent)); receive(message); MutableSpan consumer = testSpanHandler.takeRemoteSpan(CONSUMER); assertChildOf(consumer, parent); TraceContext messageContext = parseB3SingleFormat(message.getStringProperty("b3")).context(); assertThat(messageContext.traceIdString()).isEqualTo(consumer.traceId()); assertThat(messageContext.spanIdString()).isEqualTo(consumer.id()); }
@Test public void receive_retains_baggage_properties() throws Exception { ActiveMQTextMessage message = new ActiveMQTextMessage(); B3Propagation.B3_STRING.injector(SETTER).inject(parent, message); message.setStringProperty(BAGGAGE_FIELD_KEY, ""); receive(message); assertThat(message.getProperties()) .containsEntry(BAGGAGE_FIELD_KEY, ""); testSpanHandler.takeRemoteSpan(CONSUMER); }