use of brave.propagation.TraceContext in project brave by openzipkin.
the class AWSPropagationTest method injectExtraStuff.
@Test
public void injectExtraStuff() {
AWSPropagation.Extra extra = new AWSPropagation.Extra();
extra.fields = ";Robot=Hello;TotalTimeSoFar=112ms;CalledFrom=Foo";
TraceContext extraContext = sampledContext.toBuilder().extra(Arrays.asList(extra)).build();
injector.inject(extraContext, carrier);
assertThat(carrier).containsEntry("x-amzn-trace-id", "Root=1-67891233-abcdef012345678912345678;Parent=463ac35c9f6413ad;Sampled=1;Robot=Hello;TotalTimeSoFar=112ms;CalledFrom=Foo");
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class AWSPropagationTest method traceIdWhenPassThrough_nullOnTruncated.
@Test
public void traceIdWhenPassThrough_nullOnTruncated() {
carrier.put("x-amzn-trace-id", "Root=1-58211399-36d228ad5d99923122bbe3");
TraceContext context = contextWithPassThrough();
assertThat(AWSPropagation.traceId(context)).isNull();
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class ITTracingClientInterceptor method usesParentFromInvocationTime.
/**
* This tests that the parent is determined at the time the request was made, not when the request
* was executed.
*/
@Test
public void usesParentFromInvocationTime() throws Exception {
server.enqueueDelay(TimeUnit.SECONDS.toMillis(1));
GreeterGrpc.GreeterFutureStub futureStub = GreeterGrpc.newFutureStub(client);
brave.Span parent = tracer.newTrace().name("test").start();
try (Tracer.SpanInScope ws = tracer.withSpanInScope(parent)) {
futureStub.sayHello(HELLO_REQUEST);
futureStub.sayHello(HELLO_REQUEST);
} finally {
parent.finish();
}
brave.Span otherSpan = tracer.newTrace().name("test2").start();
try (Tracer.SpanInScope ws = tracer.withSpanInScope(otherSpan)) {
for (int i = 0; i < 2; i++) {
TraceContext context = server.takeRequest().context();
assertThat(context.traceId()).isEqualTo(parent.context().traceId());
assertThat(context.parentId()).isEqualTo(parent.context().spanId());
}
} finally {
otherSpan.finish();
}
// Check we reported 2 local spans and 2 client spans
assertThat(Arrays.asList(spans.take(), spans.take(), spans.take(), spans.take())).extracting(Span::kind).containsOnly(null, Span.Kind.CLIENT);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class ITTracingClientInterceptor method propagatesSpan.
@Test
public void propagatesSpan() throws Exception {
GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
TraceContext context = server.takeRequest().context();
assertThat(context.parentId()).isNull();
assertThat(context.sampled()).isTrue();
spans.take();
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class HttpClientHandlerTest method handleSend_injectsTheTraceContext_onTheCarrier.
@Test
public void handleSend_injectsTheTraceContext_onTheCarrier() {
Object customCarrier = new Object();
TraceContext context = handler.handleSend(injector, customCarrier, request).context();
verify(injector).inject(context, customCarrier);
}
Aggregations