Search in sources :

Example 1 with SpanContext

use of com.uber.jaeger.SpanContext in project cxf by apache.

the class OpenTracingTracingTest method testThatOuterSpanIsCreatedUsingAsyncInvocation.

@Test
public void testThatOuterSpanIsCreatedUsingAsyncInvocation() {
    final SpanContext spanId = fromRandom();
    final Response r = withTrace(createWebClient("/bookstore/books/async/notrace"), spanId).get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertThat(TestSender.getAllSpans().size(), equalTo(1));
    assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("GET /bookstore/books/async/notrace"));
}
Also used : Response(javax.ws.rs.core.Response) SpanContext(com.uber.jaeger.SpanContext) Test(org.junit.Test)

Example 2 with SpanContext

use of com.uber.jaeger.SpanContext in project cxf by apache.

the class OpenTracingTracingTest method testThatNewInnerSpanIsCreated.

@Test
public void testThatNewInnerSpanIsCreated() {
    final SpanContext spanId = fromRandom();
    final Response r = withTrace(createWebClient("/bookstore/books"), spanId).get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertThat(TestSender.getAllSpans().size(), equalTo(2));
    assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("Get Books"));
    assertThat(TestSender.getAllSpans().get(1).getOperationName(), equalTo("GET /bookstore/books"));
}
Also used : Response(javax.ws.rs.core.Response) SpanContext(com.uber.jaeger.SpanContext) Test(org.junit.Test)

Example 3 with SpanContext

use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.

the class B3TextMapCodecTest method testExtract_childSpan.

@Test
public void testExtract_childSpan() throws Exception {
    SpanId spanId = SpanId.builder().spanId(2L).traceId(1L).parentId(1L).build();
    TextMap textMap = makeRequestWithSpanId(spanId);
    SpanContext context = b3Codec.extract(textMap);
    assertEquals(1, context.getTraceId());
    assertEquals(1, context.getParentId());
    assertEquals(2, context.getSpanId());
    // sampled
    assertEquals(1, context.getFlags());
}
Also used : SpanContext(com.uber.jaeger.SpanContext) TextMap(io.opentracing.propagation.TextMap) SpanId(com.github.kristofa.brave.SpanId) Test(org.junit.Test)

Example 4 with SpanContext

use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.

the class B3TextMapCodecTest method testInject_unsampled.

@Test
public void testInject_unsampled() throws Exception {
    DelegatingTextMap textMap = new DelegatingTextMap();
    b3Codec.inject(new SpanContext(1, 1, 0, (byte) 0), textMap);
    TraceData data = takeRequestFromTextMap(textMap);
    assertEquals(Boolean.FALSE, data.getSample());
}
Also used : SpanContext(com.uber.jaeger.SpanContext) TraceData(com.github.kristofa.brave.TraceData) Test(org.junit.Test)

Example 5 with SpanContext

use of com.uber.jaeger.SpanContext in project jaeger-client-java by jaegertracing.

the class B3TextMapCodecTest method testExtract_rootSpan.

@Test
public void testExtract_rootSpan() throws Exception {
    SpanId spanId = SpanId.builder().spanId(1L).traceId(1L).parentId(null).build();
    TextMap textMap = makeRequestWithSpanId(spanId);
    SpanContext context = b3Codec.extract(textMap);
    assertEquals(1, context.getTraceId());
    // parentID==0 means root span
    assertEquals(0, context.getParentId());
    assertEquals(1, context.getSpanId());
    // sampled
    assertEquals(1, context.getFlags());
}
Also used : SpanContext(com.uber.jaeger.SpanContext) TextMap(io.opentracing.propagation.TextMap) SpanId(com.github.kristofa.brave.SpanId) Test(org.junit.Test)

Aggregations

SpanContext (com.uber.jaeger.SpanContext)29 Test (org.junit.Test)25 TextMap (io.opentracing.propagation.TextMap)6 Response (javax.ws.rs.core.Response)6 Span (com.uber.jaeger.Span)5 TraceData (com.github.kristofa.brave.TraceData)3 HashMap (java.util.HashMap)3 SpanId (com.github.kristofa.brave.SpanId)2 Tracer (com.uber.jaeger.Tracer)2 Span (io.opentracing.Span)2 List (java.util.List)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 Endpoint (com.twitter.zipkin.thriftjava.Endpoint)1 ObservedSpan (com.uber.jaeger.crossdock.api.ObservedSpan)1 ConstSampler (com.uber.jaeger.samplers.ConstSampler)1 SpanRef (com.uber.jaeger.thriftjava.SpanRef)1 TextMapExtractAdapter (io.opentracing.propagation.TextMapExtractAdapter)1 TextMapInjectAdapter (io.opentracing.propagation.TextMapInjectAdapter)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1