use of com.google.devtools.cloudtrace.v1.TraceSpan.SpanKind in project spring-cloud-gcp by spring-cloud.
the class SpanTranslator method translate.
TraceSpan.Builder translate(TraceSpan.Builder spanBuilder, Span zipkinSpan) {
// It's possible to have an empty name when the Span is generated from ane error.
spanBuilder.setName(zipkinSpan.name() == null ? "" : zipkinSpan.name());
SpanKind kind = getSpanKind(zipkinSpan.kind());
spanBuilder.setKind(kind);
rewriteIds(zipkinSpan, spanBuilder, kind);
if (zipkinSpan.timestampAsLong() != 0L) {
spanBuilder.setStartTime(createTimestamp(zipkinSpan.timestamp()));
if (zipkinSpan.durationAsLong() != 0) {
Timestamp endTime = createTimestamp(zipkinSpan.timestampAsLong() + zipkinSpan.durationAsLong());
spanBuilder.setEndTime(endTime);
}
}
spanBuilder.putAllLabels(this.labelExtractor.extract(zipkinSpan));
return spanBuilder;
}
use of com.google.devtools.cloudtrace.v1.TraceSpan.SpanKind in project zipkin-gcp by openzipkin.
the class SpanTranslator method translate.
/**
* Converts a Zipkin Span into a Stackdriver Trace Span.
*
* Ex.
* <pre>{@code
* traceSpan = SpanTranslator.translate(TraceSpan.newBuilder(), zipkinSpan).build();
* }</pre>
*
* <p>Note: the result does not include the trace ID from the input.
*
* @param spanBuilder the builder (to facilitate re-use)
* @param zipkinSpan The Zipkin Span.
* @return A Stackdriver Trace Span.
*/
public static TraceSpan.Builder translate(TraceSpan.Builder spanBuilder, Span zipkinSpan) {
spanBuilder.setName(zipkinSpan.name() != null ? zipkinSpan.name() : "");
SpanKind kind = getSpanKind(zipkinSpan.kind());
spanBuilder.setKind(kind);
rewriteIds(zipkinSpan, spanBuilder, kind);
if (zipkinSpan.timestampAsLong() != 0L) {
spanBuilder.setStartTime(createTimestamp(zipkinSpan.timestampAsLong()));
if (zipkinSpan.durationAsLong() != 0L) {
Timestamp endTime = createTimestamp(zipkinSpan.timestampAsLong() + zipkinSpan.durationAsLong());
spanBuilder.setEndTime(endTime);
}
}
spanBuilder.putAllLabels(labelExtractor.extract(zipkinSpan));
return spanBuilder;
}