Search in sources :

Example 56 with TraceContext

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);
}
Also used : StrictCurrentTraceContext(brave.propagation.StrictCurrentTraceContext) CurrentTraceContext(brave.propagation.CurrentTraceContext) TraceContext(brave.propagation.TraceContext) Test(org.junit.Test)

Example 57 with TraceContext

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();
}
Also used : StrictCurrentTraceContext(brave.propagation.StrictCurrentTraceContext) CurrentTraceContext(brave.propagation.CurrentTraceContext) TraceContext(brave.propagation.TraceContext) Test(org.junit.Test)

Example 58 with TraceContext

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));
}
Also used : TraceContext(brave.propagation.TraceContext) Test(org.junit.Test)

Example 59 with TraceContext

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);
}
Also used : TraceContext(brave.propagation.TraceContext) Test(org.junit.Test)

Example 60 with TraceContext

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);
}
Also used : StrictCurrentTraceContext(brave.propagation.StrictCurrentTraceContext) CurrentTraceContext(brave.propagation.CurrentTraceContext) TraceContext(brave.propagation.TraceContext) Test(org.junit.Test)

Aggregations

TraceContext (brave.propagation.TraceContext)200 Test (org.junit.Test)163 CurrentTraceContext (brave.propagation.CurrentTraceContext)77 Scope (brave.propagation.CurrentTraceContext.Scope)52 StrictCurrentTraceContext (brave.propagation.StrictCurrentTraceContext)52 MutableSpan (brave.handler.MutableSpan)38 Span (brave.Span)17 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 MockResponse (okhttp3.mockwebserver.MockResponse)12 SpanHandler (brave.handler.SpanHandler)9 Clock (brave.Clock)7 SamplingFlags (brave.propagation.SamplingFlags)7 TraceContextOrSamplingFlags (brave.propagation.TraceContextOrSamplingFlags)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7 AtomicReference (java.util.concurrent.atomic.AtomicReference)7 TestSpanHandler (brave.test.TestSpanHandler)6 AssertableCallback (brave.test.util.AssertableCallback)6 Message (javax.jms.Message)6 After (org.junit.After)6