.setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build());
.setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.build());
.setProjectId(projectId) .setTraceId(formatTraceId(context.getTraceId())) .addSpans(spanBuilder.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(); }
/** * 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(); }
@Override public void report(Span span) { Assert.notNull(span, "span cannot be null"); if (span.isExportable()) { TraceSpan traceSpan = convert(span); Traces traces = Traces.newBuilder() .addTraces(Trace.newBuilder() .setTraceId(formatTraceId(span)) .setProjectId(this.projectId) .addSpans(traceSpan) .build()) .build(); this.traceConsumer.receive(traces); } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("The span " + span + " will not be sent to Stackdriver Trace due to sampling"); } } } }
/** * 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 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 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 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(); }
/** * Returns all of the trace messages in this trace buffer. * * @return an iterable containing the trace messages in this trace buffer. */ public Traces getTraces() { Traces.Builder tracesBuilder = Traces.newBuilder(); for (Map.Entry<TraceKey, SpanBuffer> entry : traceMap.entrySet()) { Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(entry.getKey().getProjectId()) .setTraceId(entry.getKey().getTraceId()); for (TraceSpan.Builder spanBuilder : entry.getValue().getSpans()) { traceBuilder.addSpans(spanBuilder); } tracesBuilder.addTraces(traceBuilder); } return tracesBuilder.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 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(); }
/** * Returns all of the trace messages in this trace buffer. * * @return an iterable containing the trace messages in this trace buffer. */ public Traces getTraces() { Traces.Builder tracesBuilder = Traces.newBuilder(); for (Map.Entry<TraceKey, SpanBuffer> entry : traceMap.entrySet()) { Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(entry.getKey().getProjectId()) .setTraceId(entry.getKey().getTraceId()); for (TraceSpan.Builder spanBuilder : entry.getValue().getSpans()) { traceBuilder.addSpans(spanBuilder); } tracesBuilder.addTraces(traceBuilder); } return tracesBuilder.build(); }
/** * Returns all of the trace messages in this trace buffer. * * @return an iterable containing the trace messages in this trace buffer. */ public Traces getTraces() { Traces.Builder tracesBuilder = Traces.newBuilder(); for (Map.Entry<TraceKey, SpanBuffer> entry : traceMap.entrySet()) { Trace.Builder traceBuilder = Trace.newBuilder() .setProjectId(entry.getKey().getProjectId()) .setTraceId(entry.getKey().getTraceId()); for (TraceSpan.Builder spanBuilder : entry.getValue().getSpans()) { traceBuilder.addSpans(spanBuilder); } tracesBuilder.addTraces(traceBuilder); } return tracesBuilder.build(); }
private void appendSpan(Trace.Builder builder, Span zipkinSpan) { TraceSpan span = translator.translate(TraceSpan.newBuilder(), zipkinSpan).build(); builder.addSpans(span); }