use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method starts_new_trace_if_none_exists.
@Test
public void starts_new_trace_if_none_exists() throws Throwable {
Message message = MessageBuilder.withBody(new byte[0]).build();
onMessageConsumed(message);
assertThat(spans).extracting(MutableSpan::kind).containsExactly(CONSUMER, null);
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method consumer_has_remote_service_name.
@Test
public void consumer_has_remote_service_name() throws Throwable {
Message message = MessageBuilder.withBody(new byte[0]).build();
onMessageConsumed(message);
assertThat(spans).extracting(MutableSpan::remoteServiceName).containsExactly("my-exchange", null);
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method continues_parent_trace_single_header.
@Test
public void continues_parent_trace_single_header() throws Throwable {
MessageProperties props = new MessageProperties();
props.setHeader("b3", TRACE_ID + "-" + SPAN_ID + "-" + SAMPLED);
Message message = MessageBuilder.withBody(new byte[0]).andProperties(props).build();
onMessageConsumed(message);
// cleared the headers to later work doesn't try to use the old parent
assertThat(message.getMessageProperties().getHeaders()).isEmpty();
assertThat(spans).filteredOn(span -> span.kind() == CONSUMER).extracting(MutableSpan::parentId).contains(SPAN_ID);
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method retains_baggage_headers.
@Test
public void retains_baggage_headers() throws Throwable {
MessageProperties props = new MessageProperties();
props.setHeader("b3", TRACE_ID + "-" + SPAN_ID + "-" + SAMPLED);
props.setHeader(BAGGAGE_FIELD_KEY, "");
Message message = MessageBuilder.withBody(new byte[0]).andProperties(props).build();
onMessageConsumed(message);
assertThat(message.getMessageProperties().getHeaders()).hasSize(// clears b3
1).containsEntry(BAGGAGE_FIELD_KEY, "");
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method consumer_span_starts_before_listener.
@Test
public void consumer_span_starts_before_listener() throws Throwable {
Message message = MessageBuilder.withBody(new byte[0]).build();
onMessageConsumed(message);
// make sure one before the other
assertThat(spans.get(0).startTimestamp()).isLessThan(spans.get(1).startTimestamp());
// make sure they finished
assertThat(spans.get(0).finishTimestamp()).isPositive();
assertThat(spans.get(1).finishTimestamp()).isPositive();
}
Aggregations