@Test public void testSpanLogsCreateAnnotations() { JaegerSpan span = tracer.buildSpan("span-with-logs").start(); span.log("event"); 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); com.twitter.zipkin.thriftjava.Span zipkinSpan = ThriftSpanConverter.convertSpan(span); List<String> annotationValues = new ArrayList<String>(); for (Annotation annotation : zipkinSpan.getAnnotations()) { annotationValues.add(annotation.getValue()); } List<String> expectedValues = new ArrayList<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); }
public static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerTracer tracer = jaegerSpan.getTracer(); Endpoint host = new Endpoint(tracer.getIpv4(), (short) 0, tracer.getServiceName()); JaegerSpanContext context = jaegerSpan.context(); return new com.twitter.zipkin.thriftjava.Span( context.getTraceIdLow(), jaegerSpan.getOperationName(), context.getSpanId(), buildAnnotations(jaegerSpan, host), buildBinaryAnnotations(jaegerSpan, host)) .setParent_id(context.getParentId()) .setTrace_id_high(context.getTraceIdHigh()) .setDebug(context.isDebug()) .setTimestamp(jaegerSpan.getStart()) .setDuration(jaegerSpan.getDuration()); }
ThriftSpanConverter { public static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerTracer tracer = jaegerSpan.getTracer(); Endpoint host = new Endpoint(tracer.getIpv4(), (short) 0, tracer.getServiceName()); JaegerSpanContext context = jaegerSpan.context(); return new com.twitter.zipkin.thriftjava.Span( context.getTraceIdLow(), jaegerSpan.getOperationName(), context.getSpanId(), buildAnnotations(jaegerSpan, host), buildBinaryAnnotations(jaegerSpan, host)) .setParent_id(context.getParentId()) .setTrace_id_high(context.getTraceIdHigh()) .setDebug(context.isDebug()) .setTimestamp(jaegerSpan.getStart()) .setDuration(jaegerSpan.getDuration()); } }
ThriftSpanConverter { public static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerTracer tracer = jaegerSpan.getTracer(); Endpoint host = new Endpoint(tracer.getIpv4(), (short) 0, tracer.getServiceName()); JaegerSpanContext context = jaegerSpan.context(); return new com.twitter.zipkin.thriftjava.Span( context.getTraceIdLow(), jaegerSpan.getOperationName(), context.getSpanId(), buildAnnotations(jaegerSpan, host), buildBinaryAnnotations(jaegerSpan, host)) .setParent_id(context.getParentId()) .setTrace_id_high(context.getTraceIdHigh()) .setDebug(context.isDebug()) .setTimestamp(jaegerSpan.getStart()) .setDuration(jaegerSpan.getDuration()); }  }
ThriftSpanConverter { public static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerTracer tracer = jaegerSpan.getTracer(); Endpoint host = new Endpoint(tracer.getIpv4(), (short) 0, tracer.getServiceName()); JaegerSpanContext context = jaegerSpan.context(); return new com.twitter.zipkin.thriftjava.Span( context.getTraceIdLow(), jaegerSpan.getOperationName(), context.getSpanId(), buildAnnotations(jaegerSpan, host), buildBinaryAnnotations(jaegerSpan, host)) .setParent_id(context.getParentId()) .setTrace_id_high(context.getTraceIdHigh()) .setDebug(context.isDebug()) .setTimestamp(jaegerSpan.getStart()) .setDuration(jaegerSpan.getDuration()); }  static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan); static Endpoint extractPeerEndpoint(Map<String, Object> tags); }
ThriftSpanConverter { public static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerTracer tracer = jaegerSpan.getTracer(); Endpoint host = new Endpoint(tracer.getIpv4(), (short) 0, tracer.getServiceName()); JaegerSpanContext context = jaegerSpan.context(); return new com.twitter.zipkin.thriftjava.Span( context.getTraceIdLow(), jaegerSpan.getOperationName(), context.getSpanId(), buildAnnotations(jaegerSpan, host), buildBinaryAnnotations(jaegerSpan, host)) .setParent_id(context.getParentId()) .setTrace_id_high(context.getTraceIdHigh()) .setDebug(context.isDebug()) .setTimestamp(jaegerSpan.getStart()) .setDuration(jaegerSpan.getDuration()); }  static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan); static Endpoint extractPeerEndpoint(Map<String, Object> tags);  }