use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingMessagePostProcessorTest method should_resume_headers.
@Test
public void should_resume_headers() {
Message message = MessageBuilder.withBody(new byte[0]).build();
message.getMessageProperties().setHeader("b3", B3SingleFormat.writeB3SingleFormat(parent));
Message postProcessMessage = tracingMessagePostProcessor.postProcessMessage(message);
assertThat(spans.get(0).parentId()).isEqualTo(parent.spanIdString());
Map<String, Object> headers = postProcessMessage.getMessageProperties().getHeaders();
assertThat(headers.get("b3").toString()).endsWith("-" + spans.get(0).id() + "-1");
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingMessagePostProcessorTest method should_prefer_current_span.
@Test
public void should_prefer_current_span() {
// Will be either a bug, or a missing processor stage which can result in an old span in headers
Message message = MessageBuilder.withBody(new byte[0]).build();
message.getMessageProperties().setHeader("b3", B3SingleFormat.writeB3SingleFormat(grandparent));
Message postProcessMessage;
try (Scope scope = tracing.currentTraceContext().newScope(parent)) {
postProcessMessage = tracingMessagePostProcessor.postProcessMessage(message);
}
assertThat(spans.get(0).parentId()).isEqualTo(parent.spanIdString());
Map<String, Object> headers = postProcessMessage.getMessageProperties().getHeaders();
assertThat(headers.get("b3").toString()).endsWith("-" + spans.get(0).id() + "-1");
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingMessagePostProcessorTest method should_report_span.
@Test
public void should_report_span() {
Message message = MessageBuilder.withBody(new byte[0]).build();
tracingMessagePostProcessor.postProcessMessage(message);
assertThat(spans).hasSize(1);
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingMessagePostProcessorTest method should_retain_baggage.
@Test
public void should_retain_baggage() {
Message message = MessageBuilder.withBody(new byte[0]).build();
message.getMessageProperties().setHeader("b3", B3SingleFormat.writeB3SingleFormat(parent));
message.getMessageProperties().setHeader(BAGGAGE_FIELD_KEY, "");
Message postProcessMessage = tracingMessagePostProcessor.postProcessMessage(message);
assertThat(spans.get(0).parentId()).isEqualTo(parent.spanIdString());
Map<String, Object> headers = postProcessMessage.getMessageProperties().getHeaders();
assertThat(headers.get("b3").toString()).endsWith("-" + spans.get(0).id() + "-1");
assertThat(headers.get(BAGGAGE_FIELD_KEY).toString()).isEmpty();
}
use of org.springframework.amqp.core.Message in project brave by openzipkin.
the class TracingRabbitListenerAdviceTest method consumer_and_listener_have_names.
@Test
public void consumer_and_listener_have_names() throws Throwable {
Message message = MessageBuilder.withBody(new byte[0]).build();
onMessageConsumed(message);
assertThat(spans).extracting(MutableSpan::name).containsExactly("next-message", "on-message");
}
Aggregations