use of brave.handler.MutableSpan in project brave by openzipkin.
the class ITTracingJMSConsumer method receiveResumesTrace.
void receiveResumesTrace(Runnable send) {
TraceContext parent = newTraceContext(SamplingFlags.SAMPLED);
producer.setProperty("b3", parent.traceIdString() + "-" + parent.spanIdString() + "-1");
send.run();
Message received = consumer.receive();
MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
assertChildOf(consumerSpan, parent);
assertThat(getPropertyIfString(received, "b3")).isEqualTo(parent.traceIdString() + "-" + consumerSpan.id() + "-1");
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class ITTracingJMSConsumer method messageListener_resumesTrace.
void messageListener_resumesTrace(Runnable send) {
consumer.setMessageListener(m -> {
// 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));
});
TraceContext parent = newTraceContext(SamplingFlags.SAMPLED);
producer.setProperty("b3", parent.traceIdString() + "-" + parent.spanIdString() + "-1");
send.run();
MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
MutableSpan listenerSpan = testSpanHandler.takeLocalSpan();
assertChildOf(consumerSpan, parent);
assertChildOf(listenerSpan, consumerSpan);
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 TracingJMSConsumerTest method receive_continues_parent_trace_single_header.
@Test
public void receive_continues_parent_trace_single_header() throws Exception {
ActiveMQTextMessage message = new ActiveMQTextMessage();
message.setStringProperty("b3", B3SingleFormat.writeB3SingleFormatWithoutParentId(parent));
receive(message);
// Ensure the current span in on the message, not the parent
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());
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class TracingMessageListenerTest method continues_parent_trace_single_header.
@Test
public void continues_parent_trace_single_header() {
ActiveMQTextMessage message = new ActiveMQTextMessage();
setStringProperty(message, "b3", B3SingleFormat.writeB3SingleFormatWithoutParentId(parent));
onMessageConsumed(message);
// clearing headers ensures later work doesn't try to use the old parent
assertNoProperties(message);
MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
MutableSpan listenerSpan = testSpanHandler.takeLocalSpan();
assertChildOf(consumerSpan, parent);
assertChildOf(listenerSpan, consumerSpan);
}
use of brave.handler.MutableSpan in project brave by openzipkin.
the class IntegrationTestSpanHandler method takeLocalSpan.
/**
* Blocks until a local span was finished. This does <em>not</em> verify errors.
*/
public MutableSpan takeLocalSpan() {
MutableSpan result = doTakeSpan(false);
assertThat(result.kind()).withFailMessage("Expected %s to have no kind", result).isNull();
assertThat(result.remoteServiceName()).withFailMessage("Expected %s to have no remote endpoint", result).isNull();
return result;
}
Aggregations