use of brave.handler.MutableSpan in project brave by openzipkin.
the class ITJms_1_1_TracingMessageProducer method should_prefer_current_to_stale_b3_header.
@Test
public void should_prefer_current_to_stale_b3_header() throws JMSException {
jms.setReadOnlyProperties(message, false);
setStringProperty(message, "b3", writeB3SingleFormat(newTraceContext(SamplingFlags.NOT_SAMPLED)));
TraceContext parent = newTraceContext(SamplingFlags.SAMPLED);
try (Scope scope = currentTraceContext.newScope(parent)) {
messageProducer.send(jms.destination, message);
}
Message received = messageConsumer.receive();
MutableSpan producerSpan = testSpanHandler.takeRemoteSpan(PRODUCER);
assertChildOf(producerSpan, parent);
assertThat(propertiesToMap(received)).containsAllEntriesOf(existingProperties).containsEntry("b3", producerSpan.traceId() + "-" + producerSpan.id() + "-1");
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class ITJms_1_1_TracingMessageProducer method should_record_properties.
void should_record_properties(Map<String, String> producerTags) {
MutableSpan producerSpan = testSpanHandler.takeRemoteSpan(PRODUCER);
assertThat(producerSpan.name()).isEqualTo("send");
assertThat(producerSpan.tags()).containsAllEntriesOf(producerTags);
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class ITTracingJMSProducer method should_not_serialize_parent_span_id.
@Test
public void should_not_serialize_parent_span_id() {
TraceContext parent = newTraceContext(SamplingFlags.SAMPLED);
try (Scope scope = currentTraceContext.newScope(parent)) {
producer.send(jms.queue, "foo");
}
Message received = consumer.receive();
MutableSpan producerSpan = testSpanHandler.takeRemoteSpan(PRODUCER);
assertChildOf(producerSpan, parent);
assertThat(propertiesToMap(received)).containsAllEntriesOf(existingProperties).containsEntry("b3", producerSpan.traceId() + "-" + producerSpan.id() + "-1");
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class ITJms_1_1_TracingMessageConsumer method messageListener_startsNewTrace.
void messageListener_startsNewTrace(JMSRunnable send, MessageConsumer messageConsumer, Map<String, String> consumerTags) throws JMSException {
messageConsumer.setMessageListener(m -> {
tracing.tracer().currentSpanCustomizer().name("message-listener");
// clearing headers ensures later work doesn't try to use the old parent
String b3 = getPropertyIfString(m, "b3");
tracing.tracer().currentSpanCustomizer().tag("b3", String.valueOf(b3 != null));
});
send.run();
MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
MutableSpan listenerSpan = testSpanHandler.takeLocalSpan();
assertThat(consumerSpan.name()).isEqualTo("receive");
// root span
assertThat(consumerSpan.parentId()).isNull();
assertThat(consumerSpan.tags()).containsAllEntriesOf(consumerTags);
assertChildOf(listenerSpan, consumerSpan);
// overridden name
assertThat(listenerSpan.name()).isEqualTo("message-listener");
assertThat(listenerSpan.tags()).hasSize(// no redundant copy of consumer tags
1).containsEntry("b3", // b3 header not leaked to listener
"false");
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class ITJms_1_1_TracingMessageConsumer method receive_startsNewTrace.
void receive_startsNewTrace(JMSRunnable send, MessageConsumer messageConsumer, Map<String, String> consumerTags) throws JMSException {
send.run();
messageConsumer.receive();
MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
assertThat(consumerSpan.name()).isEqualTo("receive");
// root span
assertThat(consumerSpan.parentId()).isNull();
assertThat(consumerSpan.tags()).containsAllEntriesOf(consumerTags);
}
Aggregations