@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()); }
public static io.jaegertracing.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerSpanContext context = jaegerSpan.context(); boolean oneChildOfParent = jaegerSpan.getReferences().size() == 1 && References.CHILD_OF.equals(jaegerSpan.getReferences().get(0).getType()); List<SpanRef> references = oneChildOfParent ? Collections.<SpanRef>emptyList() : buildReferences(jaegerSpan.getReferences()); return new io.jaegertracing.thriftjava.Span( context.getTraceIdLow(), context.getTraceIdHigh(), context.getSpanId(), oneChildOfParent ? context.getParentId() : 0, jaegerSpan.getOperationName(), context.getFlags(), jaegerSpan.getStart(), jaegerSpan.getDuration() ) .setReferences(references) .setTags(buildTags(jaegerSpan.getTags())) .setLogs(buildLogs(jaegerSpan.getLogs())); }
JaegerThriftSpanConverter { public static io.jaegertracing.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerSpanContext context = jaegerSpan.context(); boolean oneChildOfParent = jaegerSpan.getReferences().size() == 1 && References.CHILD_OF.equals(jaegerSpan.getReferences().get(0).getType()); List<SpanRef> references = oneChildOfParent ? Collections.<SpanRef>emptyList() : buildReferences(jaegerSpan.getReferences()); return new io.jaegertracing.thriftjava.Span( context.getTraceIdLow(), context.getTraceIdHigh(), context.getSpanId(), oneChildOfParent ? context.getParentId() : 0, jaegerSpan.getOperationName(), context.getFlags(), jaegerSpan.getStart(), jaegerSpan.getDuration() ) .setReferences(references) .setTags(buildTags(jaegerSpan.getTags())) .setLogs(buildLogs(jaegerSpan.getLogs())); } }
JaegerThriftSpanConverter { public static io.jaegertracing.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerSpanContext context = jaegerSpan.context(); boolean oneChildOfParent = jaegerSpan.getReferences().size() == 1 && References.CHILD_OF.equals(jaegerSpan.getReferences().get(0).getType()); List<SpanRef> references = oneChildOfParent ? Collections.<SpanRef>emptyList() : buildReferences(jaegerSpan.getReferences()); return new io.jaegertracing.thriftjava.Span( context.getTraceIdLow(), context.getTraceIdHigh(), context.getSpanId(), oneChildOfParent ? context.getParentId() : 0, jaegerSpan.getOperationName(), context.getFlags(), jaegerSpan.getStart(), jaegerSpan.getDuration() ) .setReferences(references) .setTags(buildTags(jaegerSpan.getTags())) .setLogs(buildLogs(jaegerSpan.getLogs())); } private  JaegerThriftSpanConverter(); }
JaegerThriftSpanConverter { public static io.jaegertracing.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerSpanContext context = jaegerSpan.context(); boolean oneChildOfParent = jaegerSpan.getReferences().size() == 1 && References.CHILD_OF.equals(jaegerSpan.getReferences().get(0).getType()); List<SpanRef> references = oneChildOfParent ? Collections.<SpanRef>emptyList() : buildReferences(jaegerSpan.getReferences()); return new io.jaegertracing.thriftjava.Span( context.getTraceIdLow(), context.getTraceIdHigh(), context.getSpanId(), oneChildOfParent ? context.getParentId() : 0, jaegerSpan.getOperationName(), context.getFlags(), jaegerSpan.getStart(), jaegerSpan.getDuration() ) .setReferences(references) .setTags(buildTags(jaegerSpan.getTags())) .setLogs(buildLogs(jaegerSpan.getLogs())); } private  JaegerThriftSpanConverter(); static io.jaegertracing.thriftjava.Span convertSpan(JaegerSpan jaegerSpan); static List<Tag> buildTags(Map<String, ?> tags); }
JaegerThriftSpanConverter { public static io.jaegertracing.thriftjava.Span convertSpan(JaegerSpan jaegerSpan) { JaegerSpanContext context = jaegerSpan.context(); boolean oneChildOfParent = jaegerSpan.getReferences().size() == 1 && References.CHILD_OF.equals(jaegerSpan.getReferences().get(0).getType()); List<SpanRef> references = oneChildOfParent ? Collections.<SpanRef>emptyList() : buildReferences(jaegerSpan.getReferences()); return new io.jaegertracing.thriftjava.Span( context.getTraceIdLow(), context.getTraceIdHigh(), context.getSpanId(), oneChildOfParent ? context.getParentId() : 0, jaegerSpan.getOperationName(), context.getFlags(), jaegerSpan.getStart(), jaegerSpan.getDuration() ) .setReferences(references) .setTags(buildTags(jaegerSpan.getTags())) .setLogs(buildLogs(jaegerSpan.getLogs())); } private  JaegerThriftSpanConverter(); static io.jaegertracing.thriftjava.Span convertSpan(JaegerSpan jaegerSpan); static List<Tag> buildTags(Map<String, ?> tags);  }