use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method toSpan.
@Test
public void toSpan() {
TraceContext context = tracer.newTrace().context();
assertThat(tracer.toSpan(context)).isInstanceOf(RealSpan.class).extracting(Span::context).containsExactly(context);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method join_createsChildWhenUnsupportedByPropagation.
@Test
public void join_createsChildWhenUnsupportedByPropagation() {
tracer = Tracing.newBuilder().propagationFactory(new Propagation.Factory() {
@Override
public <K> Propagation<K> create(Propagation.KeyFactory<K> keyFactory) {
return B3Propagation.FACTORY.create(keyFactory);
}
}).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()));
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method newChild_noop.
@Test
public void newChild_noop() {
TraceContext parent = tracer.newTrace().context();
tracer.noop.set(true);
assertThat(tracer.newChild(parent)).isInstanceOf(NoopSpan.class);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method join_ensuresSampling.
@Test
public void join_ensuresSampling() {
TraceContext notYetSampled = tracer.newTrace().context().toBuilder().sampled(null).build();
assertThat(tracer.joinSpan(notYetSampled).context()).isEqualTo(notYetSampled.toBuilder().sampled(true).build());
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method join_noop.
@Test
public void join_noop() {
TraceContext fromIncomingRequest = tracer.newTrace().context();
tracer.noop.set(true);
assertThat(tracer.joinSpan(fromIncomingRequest)).isInstanceOf(NoopSpan.class);
}
Aggregations