protected TraceSpan convert(Span span) { Span adjustedSpan = span; for (SpanAdjuster adjuster : this.spanAdjusters) { adjustedSpan = adjuster.adjust(adjustedSpan); } TraceSpan.Builder builder = TraceSpan.newBuilder(); // Set name if (StringUtils.hasText(adjustedSpan.getName())) { builder.setName(adjustedSpan.getName()); } TraceSpan.SpanKind kind = getKind(adjustedSpan); builder.setKind(kind); builder.setSpanId(adjustedSpan.getSpanId()); rewriteIds(adjustedSpan, kind, builder); writeStartEndTime(adjustedSpan, builder); builder.putAllLabels(this.labelExtractor.extract(adjustedSpan, builder.getKind(), this.instanceId)); return builder.build(); }
/** * Converts a start span event into an API v1 trace message. * * @param projectId a string that contains the Google Cloud Platform project identifier. * @param context a span context that represents the event span. * @param parentContext a span context that represents the parent span of the event span. * @param spanKind the span kind of the event span. * @param name a string containing the name of the event span. * @param timestamp a timestamp that represents the start time of the event span. * @return a trace message that represents the start span event. */ public Trace generateStartSpan(String projectId, SpanContext context, SpanContext parentContext, SpanKind spanKind, String name, Timestamp timestamp) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder() .setSpanId(context.getSpanId().getSpanId()) .setKind(toSpanKindProto(spanKind)) .setName(name) .setStartTime(toTimestamp(timestamp)); if (parentContext.getTraceId().equals(context.getTraceId()) && parentContext.getSpanId().isValid()) { spanBuilder.setParentSpanId(parentContext.getSpanId().getSpanId()); } Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
/** * Converts a start span event into an API v1 trace message. * * @param projectId a string that contains the Google Cloud Platform project identifier. * @param context a trace context that represents the event span. * @param parentContext a trace context that represents the parent span of the event span. * @param spanKind the span kind of the event span. * @param name a string containing the name of the event span. * @param timestamp a timestamp that represents the start time of the event span. * @return a trace message that represents the start span event. */ public Trace generateStartSpan(String projectId, TraceContext context, TraceContext parentContext, SpanKind spanKind, String name, Timestamp timestamp) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder() .setSpanId(context.getSpanId().getSpanId()) .setKind(toSpanKindProto(spanKind)) .setName(name) .setStartTime(toTimestamp(timestamp)); if (parentContext.getTraceId().equals(context.getTraceId()) && parentContext.getSpanId().isValid()) { spanBuilder.setParentSpanId(parentContext.getSpanId().getSpanId()); } Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
/** * Converts a start span event into an API v1 trace message. * * @param projectId a string that contains the Google Cloud Platform project identifier. * @param context a span context that represents the event span. * @param parentContext a span context that represents the parent span of the event span. * @param spanKind the span kind of the event span. * @param name a string containing the name of the event span. * @param timestamp a timestamp that represents the start time of the event span. * @return a trace message that represents the start span event. */ public Trace generateStartSpan(String projectId, SpanContext context, SpanContext parentContext, SpanKind spanKind, String name, Timestamp timestamp) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder() .setSpanId(context.getSpanId().getSpanId()) .setKind(toSpanKindProto(spanKind)) .setName(name) .setStartTime(toTimestamp(timestamp)); if (parentContext.getTraceId().equals(context.getTraceId()) && parentContext.getSpanId().isValid()) { spanBuilder.setParentSpanId(parentContext.getSpanId().getSpanId()); } Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
/** * Converts a start span event into an API v1 trace message. * * @param projectId a string that contains the Google Cloud Platform project identifier. * @param context a span context that represents the event span. * @param parentContext a span context that represents the parent span of the event span. * @param spanKind the span kind of the event span. * @param name a string containing the name of the event span. * @param timestamp a timestamp that represents the start time of the event span. * @return a trace message that represents the start span event. */ public Trace generateStartSpan(String projectId, SpanContext context, SpanContext parentContext, SpanKind spanKind, String name, Timestamp timestamp) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder() .setSpanId(context.getSpanId().getSpanId()) .setKind(toSpanKindProto(spanKind)) .setName(name) .setStartTime(toTimestamp(timestamp)); if (parentContext.getTraceId().equals(context.getTraceId()) && parentContext.getSpanId().isValid()) { spanBuilder.setParentSpanId(parentContext.getSpanId().getSpanId()); } Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
TraceSpan.Builder translate(TraceSpan.Builder spanBuilder, Span zipkinSpan) { spanBuilder.setName(zipkinSpan.name()); SpanKind kind = getSpanKind(zipkinSpan.kind()); spanBuilder.setKind(kind); rewriteIds(zipkinSpan, spanBuilder, kind); if (zipkinSpan.timestamp() != null) { spanBuilder.setStartTime(createTimestamp(zipkinSpan.timestamp())); if (zipkinSpan.duration() != null) { Timestamp endTime = createTimestamp(zipkinSpan.timestamp() + zipkinSpan.duration()); spanBuilder.setEndTime(endTime); } } spanBuilder.putAllLabels(labelExtractor.extract(zipkinSpan)); return spanBuilder; }