Search in sources :

Example 46 with JaegerSpan

use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.

the class V2SpanConverterTest method testSpanDetectsIsServer.

@Test
public void testSpanDetectsIsServer() {
    JaegerSpan span = tracer.buildSpan("test-service-operation").start();
    Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
    assertTrue(ConverterUtil.isRpc(span));
    assertFalse(ConverterUtil.isRpcClient(span));
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) Test(org.junit.Test)

Example 47 with JaegerSpan

use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.

the class JaegerThriftSpanConverterTest method testConvertSpanMixedReferences.

@Test
public void testConvertSpanMixedReferences() {
    JaegerSpan parent = tracer.buildSpan("foo").start();
    JaegerSpan parent2 = tracer.buildSpan("foo").start();
    JaegerSpan child = tracer.buildSpan("foo").addReference(References.FOLLOWS_FROM, parent.context()).asChildOf(parent2).start();
    io.jaegertracing.thriftjava.Span span = JaegerThriftSpanConverter.convertSpan(child);
    assertEquals(0, span.getParentSpanId());
    assertEquals(2, span.getReferences().size());
    assertEquals(buildReference(parent.context(), References.FOLLOWS_FROM), span.getReferences().get(0));
    assertEquals(buildReference(parent2.context(), References.CHILD_OF), span.getReferences().get(1));
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) Test(org.junit.Test)

Example 48 with JaegerSpan

use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.

the class V2SpanConverterTest method testTracerTags.

@Test
@UseDataProvider("dataProviderTracerTags")
public void testTracerTags(SpanType spanType, Map<String, String> expectedTags) {
    InMemoryReporter spanReporter = new InMemoryReporter();
    JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withSampler(new ConstSampler(true)).withZipkinSharedRpcSpan().withTag("tag.str", "y").withTag("tag.bool", true).withTag("tag.num", 1).build();
    JaegerSpan span = tracer.buildSpan("root").start();
    if (spanType == SpanType.CHILD) {
        span = tracer.buildSpan("child").asChildOf(span).start();
    } else if (spanType == SpanType.RPC_SERVER) {
        span = tracer.buildSpan("rpc-server").asChildOf(span).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).start();
    }
    zipkin2.Span zipkinSpan = V2SpanConverter.convertSpan(span);
    Map<String, String> zipkinTags = zipkinSpan.tags();
    for (Map.Entry<String, String> entry : expectedTags.entrySet()) {
        String key = entry.getKey();
        Object expectedValue = entry.getValue();
        String tagValue = zipkinTags.get(key);
        if (expectedValue.equals(UNDEF)) {
            assertNull("Not expecting " + key + " for " + spanType, tagValue);
        } else if (expectedValue.equals(ANY)) {
            assertNotNull(key, tagValue);
        } else {
            assertEquals("Expecting " + key + " for " + spanType, expectedValue, tagValue);
        }
    }
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) JaegerSpan(io.jaegertracing.internal.JaegerSpan) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) HashMap(java.util.HashMap) Map(java.util.Map) TextMap(io.opentracing.propagation.TextMap) TreeMap(java.util.TreeMap) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 49 with JaegerSpan

use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.

the class V2SpanConverterTest method testConvertSpanWith128BitTraceId.

@Test
public void testConvertSpanWith128BitTraceId() {
    // zipkinSpan.traceId() always returns full length ID (padded with 0s).
    // To make the test stable, use a short idHigh portion.
    JaegerSpanContext c = new JaegerSpanContext(1L, 1L, 1L, 0L, (byte) 0x01);
    JaegerSpan span = tracer128.buildSpan("operation-name").asChildOf(c).start();
    zipkin2.Span zipkinSpan = V2SpanConverter.convertSpan(span);
    assertNotEquals(0, span.context().getTraceIdHigh());
    assertEquals(span.context().getTraceId(), zipkinSpan.traceId());
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) Test(org.junit.Test)

Example 50 with JaegerSpan

use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.

the class TraceContextCodecTest method testDebugIdWithTraceHeader.

@Test
public void testDebugIdWithTraceHeader() {
    Map<String, String> extractCarrier = new HashMap<>();
    TextMapAdapter textMap = new TextMapAdapter(extractCarrier);
    textMap.put(TRACE_PARENT, EXAMPLE_TRACE_PARENT);
    textMap.put(Constants.DEBUG_ID_HEADER_KEY, EXAMPLE_DEBUG_ID);
    JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
    JaegerTracer tracer = new JaegerTracer.Builder("service").withReporter(new InMemoryReporter()).build();
    assertEquals("0000000000000001", spanContext.getTraceId());
    JaegerSpan child = tracer.buildSpan("span").asChildOf(spanContext).start();
    assertFalse(child.context().isDebug());
    child.finish();
    tracer.close();
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) HashMap(java.util.HashMap) JaegerSpan(io.jaegertracing.internal.JaegerSpan) TextMapAdapter(io.opentracing.propagation.TextMapAdapter) JaegerSpanContext(io.jaegertracing.internal.JaegerSpanContext) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Aggregations

JaegerSpan (io.jaegertracing.internal.JaegerSpan)51 Test (org.junit.Test)47 JaegerSpanContext (io.jaegertracing.internal.JaegerSpanContext)10 HashMap (java.util.HashMap)8 JaegerTracer (io.jaegertracing.internal.JaegerTracer)7 InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)7 ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)6 ArrayList (java.util.ArrayList)6 TreeMap (java.util.TreeMap)5 BinaryAnnotation (com.twitter.zipkin.thriftjava.BinaryAnnotation)4 SenderException (io.jaegertracing.internal.exceptions.SenderException)4 TextMap (io.opentracing.propagation.TextMap)4 TextMapAdapter (io.opentracing.propagation.TextMapAdapter)4 List (java.util.List)4 Annotation (com.twitter.zipkin.thriftjava.Annotation)3 Process (io.jaegertracing.thriftjava.Process)3 Map (java.util.Map)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 Builder (io.jaegertracing.internal.reporters.RemoteReporter.Builder)2 InMemorySender (io.jaegertracing.internal.senders.InMemorySender)2