Search in sources :

Example 16 with Annotation

use of zipkin.Annotation in project zipkin by openzipkin.

the class DependencyLinkSpan method from.

public static DependencyLinkSpan from(Span s) {
    TraceId traceId = new TraceId(s.traceIdHigh, s.traceId);
    DependencyLinkSpan.Builder linkSpan = new DependencyLinkSpan.Builder(traceId, s.parentId, s.id);
    for (BinaryAnnotation a : s.binaryAnnotations) {
        if (a.key.equals(Constants.CLIENT_ADDR) && a.endpoint != null) {
            linkSpan.caService(a.endpoint.serviceName);
        } else if (a.key.equals(Constants.SERVER_ADDR) && a.endpoint != null) {
            linkSpan.saService(a.endpoint.serviceName);
        }
    }
    for (Annotation a : s.annotations) {
        if (a.value.equals(Constants.SERVER_RECV) && a.endpoint != null) {
            linkSpan.srService(a.endpoint.serviceName);
        } else if (a.value.equals(Constants.CLIENT_SEND) && a.endpoint != null) {
            linkSpan.csService(a.endpoint.serviceName);
        }
    }
    return linkSpan.build();
}
Also used : BinaryAnnotation(zipkin.BinaryAnnotation) Annotation(zipkin.Annotation) BinaryAnnotation(zipkin.BinaryAnnotation)

Example 17 with Annotation

use of zipkin.Annotation in project jaeger-client-java by jaegertracing.

the class ZipkinSenderTest method testAppendSpanWithLogs.

@Test
public void testAppendSpanWithLogs() throws Exception {
    Span span = (Span) tracer.buildSpan("span-with-logs").startManual();
    span.log("event");
    // use sorted map for consistent ordering in test
    Map<String, Object> fields = new TreeMap<String, Object>();
    fields.put("event", "structured data");
    fields.put("string", "something");
    fields.put("number", 42);
    fields.put("boolean", true);
    span.log(fields);
    sender.append(span);
    sender.flush();
    List<List<zipkin.Span>> traces = zipkinRule.getTraces();
    assertEquals(1, traces.size());
    assertEquals(1, traces.get(0).size());
    zipkin.Span zipkinSpan = traces.get(0).get(0);
    assertEquals(2, zipkinSpan.annotations.size());
    // ignore order by using set
    Set<String> annotationValues = new HashSet<String>();
    for (Annotation annotation : zipkinSpan.annotations) {
        annotationValues.add(annotation.value);
    }
    Set<String> expectedValues = new HashSet<String>();
    expectedValues.add("event");
    expectedValues.add("{\"boolean\":true,\"event\":\"structured data\",\"number\":42,\"string\":\"something\"}");
    assertEquals("zipkin span should contain matching annotations for span logs", expectedValues, annotationValues);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap) Span(com.uber.jaeger.Span) Annotation(zipkin.Annotation) BinaryAnnotation(zipkin.BinaryAnnotation) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Annotation (zipkin.Annotation)17 BinaryAnnotation (zipkin.BinaryAnnotation)14 Span (zipkin.Span)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 Endpoint (zipkin.Endpoint)5 LinkedHashSet (java.util.LinkedHashSet)3 Span (com.uber.jaeger.Span)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 BoundStatement (com.datastax.driver.core.BoundStatement)1 SpanContext (com.uber.jaeger.SpanContext)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 DSLContext (org.jooq.DSLContext)1