use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingMessagePostProcessorTest method should_set_remote_service.
@Test
public void should_set_remote_service() {
Message message = MessageBuilder.withBody(new byte[0]).build();
tracingMessagePostProcessor.postProcessMessage(message);
assertThat(spans.get(0).remoteServiceName()).isEqualTo("my-exchange");
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method reports_span_if_consume_fails.
@Test
public void reports_span_if_consume_fails() throws Throwable {
Message message = MessageBuilder.withBody(new byte[0]).build();
RuntimeException error = new RuntimeException("Test exception");
onMessageConsumeFailed(message, error);
assertThat(spans).extracting(MutableSpan::kind).containsExactly(CONSUMER, null);
assertThat(spans).filteredOn(span -> span.kind() == null).extracting(MutableSpan::error).containsExactly(error);
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method reports_span_if_consume_fails_with_no_message.
@Test
public void reports_span_if_consume_fails_with_no_message() throws Throwable {
Message message = MessageBuilder.withBody(new byte[0]).build();
RuntimeException error = new RuntimeException("Test exception");
onMessageConsumeFailed(message, error);
assertThat(spans).extracting(MutableSpan::kind).containsExactly(CONSUMER, null);
assertThat(spans).filteredOn(span -> span.kind() == null).extracting(MutableSpan::error).containsExactly(error);
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method batch_new_trace_last_traced.
@Test
public void batch_new_trace_last_traced() throws Throwable {
MessageProperties props = new MessageProperties();
props.setHeader("X-B3-TraceId", TRACE_ID_2);
props.setHeader("X-B3-SpanId", SPAN_ID_2);
props.setHeader("X-B3-ParentSpanId", PARENT_ID_2);
props.setHeader("X-B3-Sampled", SAMPLED);
Message message = MessageBuilder.withBody(new byte[0]).build();
Message message2 = MessageBuilder.withBody(new byte[0]).andProperties(props).build();
onBatchMessageConsumed(Arrays.asList(message, message2));
// new trace
assertThat(spans.get(0)).extracting(MutableSpan::parentId).isNotEqualTo(SPAN_ID);
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method batch_continue_first_traced.
@Test
public void batch_continue_first_traced() throws Throwable {
MessageProperties props = new MessageProperties();
props.setHeader("X-B3-TraceId", TRACE_ID);
props.setHeader("X-B3-SpanId", SPAN_ID);
props.setHeader("X-B3-ParentSpanId", PARENT_ID);
props.setHeader("X-B3-Sampled", SAMPLED);
Message message = MessageBuilder.withBody(new byte[0]).andProperties(props).build();
Message message2 = MessageBuilder.withBody(new byte[0]).build();
onBatchMessageConsumed(Arrays.asList(message, message2));
// cleared the headers to later work doesn't try to use the old parent
assertThat(message.getMessageProperties().getHeaders()).isEmpty();
// first traced that listener continues that trace
assertThat(spans.get(0)).extracting(MutableSpan::parentId).isEqualTo(SPAN_ID);
}
Aggregations