use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method join_setsShared.
/**
* When we join a sampled request, we are sharing the same trace identifiers.
*/
@Test
public void join_setsShared() {
TraceContext fromIncomingRequest = tracer.newTrace().context();
tracer.joinSpan(fromIncomingRequest).start().finish();
assertThat(spans.get(0).shared()).isTrue();
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method toSpan_noop.
@Test
public void toSpan_noop() {
TraceContext context = tracer.newTrace().context();
tracer.noop.set(true);
assertThat(tracer.toSpan(context)).isInstanceOf(NoopSpan.class);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method nextSpan_extractedTraceContext.
@Test
public void nextSpan_extractedTraceContext() {
TraceContext traceContext = TraceContext.newBuilder().traceId(1L).spanId(2L).build();
TraceContextOrSamplingFlags extracted = TraceContextOrSamplingFlags.create(traceContext);
assertThat(tracer.nextSpan(extracted).context()).extracting(TraceContext::traceId, TraceContext::parentId).containsExactly(1L, 2L);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method toString_withSpanInFlight.
@Test
public void toString_withSpanInFlight() {
TraceContext context = TraceContext.newBuilder().traceId(1L).spanId(10L).sampled(true).build();
Span span = tracer.toSpan(context);
// didn't set anything else! this is to help ensure no NPE
span.start(1L);
assertThat(tracer).hasToString("Tracer{inFlight=[{\"traceId\":\"0000000000000001\",\"id\":\"000000000000000a\",\"timestamp\":1,\"localEndpoint\":{\"serviceName\":\"my-service\"}}], reporter=MyReporter{}}");
span.finish();
assertThat(tracer).hasToString("Tracer{reporter=MyReporter{}}");
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method join_createsChildWhenUnsupported.
@Test
public void join_createsChildWhenUnsupported() {
tracer = Tracing.newBuilder().supportsJoin(false).spanReporter(spans::add).build().tracer();
TraceContext fromIncomingRequest = tracer.newTrace().context();
tracer.joinSpan(fromIncomingRequest).start().finish();
assertThat(spans.get(0).shared()).isNull();
assertThat(spans.get(0).parentId()).isEqualTo(HexCodec.toLowerHex(fromIncomingRequest.spanId()));
}
Aggregations