/** * * * <pre> * Collection of spans in the trace. * </pre> * * <code>repeated .google.devtools.cloudtrace.v1.TraceSpan spans = 3;</code> */ public Builder addSpans( int index, com.google.devtools.cloudtrace.v1.TraceSpan.Builder builderForValue) { if (spansBuilder_ == null) { ensureSpansIsMutable(); spans_.add(index, builderForValue.build()); onChanged(); } else { spansBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
@java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.devtools.cloudtrace.v1.TraceSpan parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (com.google.devtools.cloudtrace.v1.TraceSpan) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; }
builder.setSpanId(rewriteId(span.getSpanId())); builder.setSpanId(span.getSpanId()); builder.setParentSpanId(rewriteId(parentId)); builder.setParentSpanId(rewriteId(span.getSpanId())); builder.setParentSpanId(parentId);
long parentId = parseUnsignedLong(zipkinSpan.parentId()); if (kind == SpanKind.RPC_CLIENT) { builder.setSpanId(rewriteId(id)); } else { builder.setSpanId(id); builder.setParentSpanId(rewriteId(id)); } else { builder.setParentSpanId(rewriteId(parentId)); builder.setParentSpanId(parentId);
/** * 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(); }
/** * 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 span label annotation 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 labels a labels containing the label annotations for the event span. * @return a trace message that represents the span label annotation event. */ public Trace generateAnnotateSpan(String projectId, TraceContext context, Labels labels) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder().setSpanId(context.getSpanId().getSpanId()); for (Label label : labels.getLabels()) { spanBuilder.putLabels(label.getKey(), label.getValue()); } Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
/** * Converts a span label annotation 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 labels a labels containing the label annotations for the event span. * @return a trace message that represents the span label annotation event. */ public Trace generateAnnotateSpan(String projectId, SpanContext context, Labels labels) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder().setSpanId(context.getSpanId().getSpanId()); for (Label label : labels.getLabels()) { spanBuilder.putLabels(label.getKey(), label.getValue()); } Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
/** * Converts a span label annotation 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 labels a labels containing the label annotations for the event span. * @return a trace message that represents the span label annotation event. */ public Trace generateAnnotateSpan(String projectId, SpanContext context, Labels labels) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder().setSpanId(context.getSpanId().getSpanId()); for (Label label : labels.getLabels()) { spanBuilder.putLabels(label.getKey(), label.getValue()); } Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
/** * Converts an end 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 timestamp a timestamp that represents the end time of the event span. * @return a trace message that represents the end span event. */ public Trace generateEndSpan(String projectId, SpanContext context, Timestamp timestamp) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder() .setSpanId(context.getSpanId().getSpanId()) .setEndTime(toTimestamp(timestamp)); Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
/** * Converts a span label annotation 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 labels a labels containing the label annotations for the event span. * @return a trace message that represents the span label annotation event. */ public Trace generateAnnotateSpan(String projectId, SpanContext context, Labels labels) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder().setSpanId(context.getSpanId().getSpanId()); for (Label label : labels.getLabels()) { spanBuilder.putLabels(label.getKey(), label.getValue()); } Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
private void writeStartEndTime(Span span, TraceSpan.Builder builder) { if (!span.isRemote()) { Log clientSend = findLog(span, Span.CLIENT_SEND); Log clientReceive = findLog(span, Span.CLIENT_RECV); if (clientSend != null) { builder.setStartTime(createTimestamp(clientSend.getTimestamp())); } else { builder.setStartTime(createTimestamp(span.getBegin())); } if (!span.isRunning()) { if (clientReceive != null) { builder.setEndTime(createTimestamp(clientReceive.getTimestamp())); } else { builder.setEndTime(createTimestamp(span.getEnd())); } } } }
/** * Converts an end 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 timestamp a timestamp that represents the end time of the event span. * @return a trace message that represents the end span event. */ public Trace generateEndSpan(String projectId, TraceContext context, Timestamp timestamp) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder() .setSpanId(context.getSpanId().getSpanId()) .setEndTime(toTimestamp(timestamp)); Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }
/** * Converts an end 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 timestamp a timestamp that represents the end time of the event span. * @return a trace message that represents the end span event. */ public Trace generateEndSpan(String projectId, SpanContext context, Timestamp timestamp) { TraceSpan.Builder spanBuilder = TraceSpan.newBuilder() .setSpanId(context.getSpanId().getSpanId()) .setEndTime(toTimestamp(timestamp)); Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build()); return traceBuilder.build(); }