use of brave.propagation.TraceContextOrSamplingFlags in project brave by openzipkin.
the class TracingRabbitListenerAdvice method invoke.
/**
* MethodInterceptor for {@link SimpleMessageListenerContainer.ContainerDelegate#invokeListener(Channel, Message)}
*/
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
Message message = (Message) methodInvocation.getArguments()[1];
TraceContextOrSamplingFlags extracted = extractTraceContextAndRemoveHeaders(message);
// named for BlockingQueueConsumer.nextMessage, which we can't currently see
Span consumerSpan = tracer.nextSpan(extracted).kind(CONSUMER).name("next-message");
Span listenerSpan = tracer.newChild(consumerSpan.context()).name("on-message");
if (!consumerSpan.isNoop()) {
consumerSpan.start();
tagReceivedMessageProperties(consumerSpan, message.getMessageProperties());
if (remoteServiceName != null) {
consumerSpan.remoteEndpoint(Endpoint.newBuilder().serviceName(remoteServiceName).build());
}
consumerSpan.finish();
listenerSpan.start();
}
try (SpanInScope ws = tracer.withSpanInScope(listenerSpan)) {
return methodInvocation.proceed();
} catch (Throwable t) {
tagErrorSpan(listenerSpan, t);
throw t;
} finally {
listenerSpan.finish();
}
}
use of brave.propagation.TraceContextOrSamplingFlags in project brave by openzipkin.
the class PropagationTest method verifyRoundTrip.
void verifyRoundTrip(TraceContextOrSamplingFlags expected) {
TraceContextOrSamplingFlags extracted = propagation().extractor(mapEntry).extract(map);
assertThat(extracted).isEqualTo(expected);
Map<K, String> injected = new LinkedHashMap<>();
if (expected.context() != null) {
propagation().injector(mapEntry).inject(expected.context(), injected);
} else {
inject(injected, expected.samplingFlags());
}
assertThat(map).isEqualTo(injected);
}
use of brave.propagation.TraceContextOrSamplingFlags in project brave by openzipkin.
the class TracerTest method nextSpan_extractedExtra_childOfCurrent.
@Test
public void nextSpan_extractedExtra_childOfCurrent() {
Span parent = tracer.newTrace();
TraceContextOrSamplingFlags extracted = TraceContextOrSamplingFlags.create(SamplingFlags.EMPTY).toBuilder().addExtra(1L).build();
try (Tracer.SpanInScope ws = tracer.withSpanInScope(parent)) {
assertThat(tracer.nextSpan(extracted).context().extra()).containsExactly(1L);
}
}
use of brave.propagation.TraceContextOrSamplingFlags in project brave by openzipkin.
the class TracerTest method nextSpan_extractedTraceId.
@Test
public void nextSpan_extractedTraceId() {
TraceIdContext traceIdContext = TraceIdContext.newBuilder().traceId(1L).build();
TraceContextOrSamplingFlags extracted = TraceContextOrSamplingFlags.create(traceIdContext);
assertThat(tracer.nextSpan(extracted).context().traceId()).isEqualTo(1L);
}
use of brave.propagation.TraceContextOrSamplingFlags in project brave by openzipkin.
the class TracerTest method nextSpan_extractedTraceContext_extra.
@Test
public void nextSpan_extractedTraceContext_extra() {
TraceContext traceContext = TraceContext.newBuilder().traceId(1L).spanId(2L).build();
TraceContextOrSamplingFlags extracted = TraceContextOrSamplingFlags.create(traceContext).toBuilder().addExtra(1L).build();
assertThat(tracer.nextSpan(extracted).context().extra()).containsExactly(1L);
}
Aggregations