use of com.google.devtools.cloudtrace.v2.SpanName in project instrumentation-java by census-instrumentation.
the class StackdriverV2ExporterHandler method generateSpan.
@VisibleForTesting
Span generateSpan(SpanData spanData, Map<String, AttributeValue> resourceLabels, Map<String, AttributeValue> fixedAttributes) {
SpanContext context = spanData.getContext();
final String spanIdHex = context.getSpanId().toLowerBase16();
SpanName spanName = SpanName.newBuilder().setProject(projectId).setTrace(context.getTraceId().toLowerBase16()).setSpan(spanIdHex).build();
Span.Builder spanBuilder = Span.newBuilder().setName(spanName.toString()).setSpanId(spanIdHex).setDisplayName(toTruncatableStringProto(toDisplayName(spanData.getName(), spanData.getKind()))).setStartTime(toTimestampProto(spanData.getStartTimestamp())).setAttributes(toAttributesProto(spanData.getAttributes(), resourceLabels, fixedAttributes)).setTimeEvents(toTimeEventsProto(spanData.getAnnotations(), spanData.getMessageEvents()));
io.opencensus.trace.Status status = spanData.getStatus();
if (status != null) {
spanBuilder.setStatus(toStatusProto(status));
}
Timestamp end = spanData.getEndTimestamp();
if (end != null) {
spanBuilder.setEndTime(toTimestampProto(end));
}
spanBuilder.setLinks(toLinksProto(spanData.getLinks()));
Integer childSpanCount = spanData.getChildSpanCount();
if (childSpanCount != null) {
spanBuilder.setChildSpanCount(Int32Value.newBuilder().setValue(childSpanCount).build());
}
if (spanData.getParentSpanId() != null && spanData.getParentSpanId().isValid()) {
spanBuilder.setParentSpanId(spanData.getParentSpanId().toLowerBase16());
}
/*@Nullable*/
Boolean hasRemoteParent = spanData.getHasRemoteParent();
if (hasRemoteParent != null) {
spanBuilder.setSameProcessAsParentSpan(BoolValue.of(!hasRemoteParent));
}
return spanBuilder.build();
}
Aggregations