Search in sources :

Example 21 with JaegerSpan

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

the class JaegerThriftSpanConverterTest method testConvertSpanOneReferenceChildOf.

@Test
public void testConvertSpanOneReferenceChildOf() {
    JaegerSpan parent = tracer.buildSpan("foo").start();
    JaegerSpan child = tracer.buildSpan("foo").asChildOf(parent).start();
    io.jaegertracing.thriftjava.Span span = JaegerThriftSpanConverter.convertSpan(child);
    assertEquals(child.context().getParentId(), span.getParentSpanId());
    assertEquals(0, span.getReferences().size());
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) Test(org.junit.Test)

Example 22 with JaegerSpan

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

the class JaegerThriftSpanConverterTest method testConvertSpanWith128BitTraceId.

@Test
public void testConvertSpanWith128BitTraceId() {
    JaegerSpan span = tracer128.buildSpan("operation-name").start();
    io.jaegertracing.thriftjava.Span thriftSpan = JaegerThriftSpanConverter.convertSpan(span);
    assertEquals(span.context().getTraceIdLow(), thriftSpan.getTraceIdLow());
    assertEquals(span.context().getTraceIdHigh(), thriftSpan.getTraceIdHigh());
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) Test(org.junit.Test)

Example 23 with JaegerSpan

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

the class JaegerThriftSpanConverterTest method testConvertSpan.

@Test
public void testConvertSpan() {
    Map<String, Object> fields = new HashMap<String, Object>();
    fields.put("k", "v");
    JaegerSpan span = tracer.buildSpan("operation-name").start();
    span = span.log(1, fields);
    span = span.setBaggageItem("foo", "bar");
    io.jaegertracing.thriftjava.Span thriftSpan = JaegerThriftSpanConverter.convertSpan(span);
    assertEquals("operation-name", thriftSpan.getOperationName());
    assertEquals(2, thriftSpan.getLogs().size());
    Log thriftLog = thriftSpan.getLogs().get(0);
    assertEquals(1, thriftLog.getTimestamp());
    assertEquals(1, thriftLog.getFields().size());
    Tag thriftTag = thriftLog.getFields().get(0);
    assertEquals("k", thriftTag.getKey());
    assertEquals("v", thriftTag.getVStr());
    thriftLog = thriftSpan.getLogs().get(1);
    assertEquals(3, thriftLog.getFields().size());
    thriftTag = thriftLog.getFields().get(0);
    assertEquals("event", thriftTag.getKey());
    assertEquals("baggage", thriftTag.getVStr());
    thriftTag = thriftLog.getFields().get(1);
    assertEquals("value", thriftTag.getKey());
    assertEquals("bar", thriftTag.getVStr());
    thriftTag = thriftLog.getFields().get(2);
    assertEquals("key", thriftTag.getKey());
    assertEquals("foo", thriftTag.getVStr());
}
Also used : HashMap(java.util.HashMap) Log(io.jaegertracing.thriftjava.Log) JaegerSpan(io.jaegertracing.internal.JaegerSpan) Tag(io.jaegertracing.thriftjava.Tag) Test(org.junit.Test)

Example 24 with JaegerSpan

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

the class JaegerThriftSpanConverterTest method testConvertSpanTwoReferencesChildOf.

@Test
public void testConvertSpanTwoReferencesChildOf() {
    JaegerSpan parent = tracer.buildSpan("foo").start();
    JaegerSpan parent2 = tracer.buildSpan("foo").start();
    JaegerSpan child = tracer.buildSpan("foo").asChildOf(parent).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.CHILD_OF), 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 25 with JaegerSpan

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

the class EndToEndBehaviorResourceTest method validateSpans.

private void validateSpans(List<JaegerSpan> spans, CreateTracesRequest request) {
    assertEquals(request.getCount(), spans.size());
    for (JaegerSpan s : spans) {
        assertEquals(request.getOperation(), s.getOperationName());
        Map<String, Object> tags = s.getTags();
        for (Map.Entry<String, String> entry : request.getTags().entrySet()) {
            assertTrue(tags.containsKey(entry.getKey()));
            Object value = tags.get(entry.getKey());
            assertEquals(entry.getValue(), value);
        }
    }
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) HashMap(java.util.HashMap) Map(java.util.Map)

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