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();
}
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);
}
Aggregations