use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method newChild_notSampledIsNoop.
@Test
public void newChild_notSampledIsNoop() {
TraceContext notSampled = tracer.newTrace().context().toBuilder().sampled(false).build();
assertThat(tracer.newChild(notSampled)).isInstanceOf(NoopSpan.class);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class TracerTest method toSpan_decorates.
@Test
public void toSpan_decorates() {
propagationFactory = baggageFactory;
TraceContext incoming = TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build();
TraceContext toSpan = tracer.toSpan(incoming).context();
assertThat(toSpan).isNotSameAs(incoming);
assertThat(toSpan.extra()).isNotEmpty();
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class MutableSpanTest method contextConstructor_contextWins.
@Test
public void contextConstructor_contextWins() {
MutableSpan span = new MutableSpan();
span.traceId("0000000000000001");
span.localRootId("0000000000000002");
span.parentId("0000000000000003");
span.id("0000000000000004");
span.setShared();
span.setDebug();
TraceContext context = TraceContext.newBuilder().traceId(10).spanId(20).build();
assertThat(new MutableSpan(context, span)).isEqualTo(new MutableSpan(context, null));
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class MutableSpanTest method contextConstructor.
@Test
public void contextConstructor() {
TraceContext context = TraceContext.newBuilder().traceId(1).spanId(2).build();
MutableSpan span = new MutableSpan();
span.traceId("0000000000000001");
span.id("0000000000000002");
assertThat(new MutableSpan(context, null)).isEqualTo(span);
// local root ID is not a public api
context = InternalPropagation.instance.newTraceContext(0, 0, 1, 2, 3, 4, emptyList());
span.traceId("0000000000000001");
span.localRootId("0000000000000002");
span.parentId("0000000000000003");
span.id("0000000000000004");
assertThat(new MutableSpan(context, null)).isEqualTo(span);
context = context.toBuilder().shared(true).build();
span.setShared();
assertThat(new MutableSpan(context, null)).isEqualTo(span);
context = context.toBuilder().debug(true).build();
span.setDebug();
assertThat(new MutableSpan(context, null)).isEqualTo(span);
}
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);
}
Aggregations