private static Iterable<? extends ZipkinCompatAnnotation> spanTypeToZipkinAnnotations( Span span, ZipkinCompatEndpoint endpoint) { List<ZipkinCompatAnnotation> annotations = Lists.newArrayListWithCapacity(2); switch (span.type()) { case CLIENT_OUTGOING: annotations.add(ZipkinCompatAnnotation.of(span.getStartTimeMicroSeconds(), "cs", endpoint)); annotations.add(ZipkinCompatAnnotation.of( span.getStartTimeMicroSeconds() + nanoToMicro(span.getDurationNanoSeconds()), "cr", endpoint)); break; case SERVER_INCOMING: annotations.add(ZipkinCompatAnnotation.of(span.getStartTimeMicroSeconds(), "sr", endpoint)); annotations.add(ZipkinCompatAnnotation.of( span.getStartTimeMicroSeconds() + nanoToMicro(span.getDurationNanoSeconds()), "ss", endpoint)); break; case LOCAL: annotations.add(ZipkinCompatAnnotation.of(span.getStartTimeMicroSeconds(), "lc", endpoint)); break; default: throw new RuntimeException("Unhandled SpanType: " + span.type()); } return annotations; }
private static Iterable<? extends ZipkinCompatAnnotation> spanTypeToZipkinAnnotations( Span span, ZipkinCompatEndpoint endpoint) { List<ZipkinCompatAnnotation> annotations = Lists.newArrayListWithCapacity(2); switch (span.type()) { case CLIENT_OUTGOING: annotations.add(ZipkinCompatAnnotation.of(span.getStartTimeMicroSeconds(), "cs", endpoint)); annotations.add(ZipkinCompatAnnotation.of( span.getStartTimeMicroSeconds() + nanoToMicro(span.getDurationNanoSeconds()), "cr", endpoint)); break; case SERVER_INCOMING: annotations.add(ZipkinCompatAnnotation.of(span.getStartTimeMicroSeconds(), "sr", endpoint)); annotations.add(ZipkinCompatAnnotation.of( span.getStartTimeMicroSeconds() + nanoToMicro(span.getDurationNanoSeconds()), "ss", endpoint)); break; case LOCAL: annotations.add(ZipkinCompatAnnotation.of(span.getStartTimeMicroSeconds(), "lc", endpoint)); break; default: throw new RuntimeException("Unhandled SpanType: " + span.type()); } return annotations; }
static ZipkinCompatSpan fromSpan(Span span, ZipkinCompatEndpoint endpoint) { return ImmutableZipkinCompatSpan.builder() .traceId(span.getTraceId()) .id(span.getSpanId()) .name(span.getOperation()) .parentId(span.getParentSpanId()) .timestamp(span.getStartTimeMicroSeconds()) .duration(nanoToMicro(span.getDurationNanoSeconds())) // Zipkin-durations are micro-seconds, round .addAllAnnotations(spanTypeToZipkinAnnotations(span, endpoint)) .addAllBinaryAnnotations(spanMetadataToZipkinBinaryAnnotations(span, endpoint)) .build(); }
static ZipkinCompatSpan fromSpan(Span span, ZipkinCompatEndpoint endpoint) { return ImmutableZipkinCompatSpan.builder() .traceId(span.getTraceId()) .id(span.getSpanId()) .name(span.getOperation()) .parentId(span.getParentSpanId()) .timestamp(span.getStartTimeMicroSeconds()) .duration(nanoToMicro(span.getDurationNanoSeconds())) // Zipkin-durations are micro-seconds, round .addAllAnnotations(spanTypeToZipkinAnnotations(span, endpoint)) .addAllBinaryAnnotations(spanMetadataToZipkinBinaryAnnotations(span, endpoint)) .build(); }