@Override public void setClientAddress(Brave brave, Endpoint ca) { Span span = brave.serverSpanThreadBinder().get(); if (span == null) return; brave.serverTracer.recorder().address(span, "ca", ca); } };
SpanId startSpan(String component, String operation, long timestamp, Span span) { recorder().start(span, timestamp); recorder().name(span, operation); recorder().tag(span, "lc", component); currentSpan().setCurrentSpan(span); return Brave.context(span); }
static SpanId getSpanId(String traceId, String spanId, String parentSpanId) { return SpanId.builder() .traceId(convertToLong(traceId)) .spanId(convertToLong(spanId)) .parentId(parentSpanId == null ? null : convertToLong(parentSpanId)).build(); }
@Override public TraceData build() { if (spanId == null) { return new AutoValue_TraceData(spanId, sample); } if (sample != null ) { return new AutoValue_TraceData(spanId.toBuilder().sampled(sample).build(), sample); } return new AutoValue_TraceData(spanId, spanId.sampled()); } }
/** * {@inheritDoc} */ @Override public Span span() { return state().getCurrentServerSpan().getSpan(); }
/** * Sets the server sent event for current thread. */ public void setServerSend() { if (submitEndAnnotation(zipkinCoreConstants.SERVER_SEND, spanCollector())) { spanAndEndpoint().state().setCurrentServerSpan(null); } }
public final Builder state(ServerClientAndLocalSpanState state) { this.currentLocalSpan = new LocalSpanThreadBinder(state); this.currentServerSpan = new ServerSpanThreadBinder(state); this.currentSpan = new ClientSpanThreadBinder(state); this.localEndpoint = state.endpoint(); return this; }
/** * Sets the 'client received' event for current thread. This will also submit span because setting a client received * event means this span is finished. */ public void setClientReceived() { if (submitEndAnnotation(zipkinCoreConstants.CLIENT_RECV, spanCollector())) { spanAndEndpoint().state().setCurrentClientSpan(null); } }
/** This adds an annotation that corresponds with {@link Span#getTimestamp()} */ void submitStartAnnotation(String startAnnotation) { Span span = currentSpan().get(); if (span == null) return; long timestamp = recorder().currentTimeMicroseconds(span); recorder().annotate(span, timestamp, startAnnotation); recorder().start(span, timestamp); }
/** * Clears current span. */ public void clearCurrentSpan() { spanAndEndpoint().state().setCurrentServerSpan(null); }
/** * Completes the span, assigning the most precise duration possible. */ public void finishSpan() { Span span = currentSpan().get(); if (span == null) return; recorder().finish(span, recorder().currentTimeMicroseconds(span)); currentSpan().setCurrentSpan(null); }
/** * Binary annotations are tags applied to a Span to give it context. For * example, a key "your_app.version" would let you lookup spans by version. * * @param key Name used to lookup spans, such as "your_app.version" * @param value String value, should not be <code>null</code>. */ public void submitBinaryAnnotation(String key, String value) { Span span = currentSpan().get(); if (span == null) return; recorder().tag(span, key, value); }
/** Internal api for submitting an address. */ void submitAddress(String key, Endpoint endpoint) { Span span = currentSpan().get(); if (span == null) return; recorder().address(span, key, endpoint); }
public final ClientTracer build() { return new AutoValue_ClientTracer( new AutoValue_Recorder_Default(localEndpoint, clock, reporter), currentLocalSpan, currentServerSpan, currentSpan, spanFactoryBuilder.build() ); }
public final ServerTracer build() { return new AutoValue_ServerTracer( new AutoValue_Recorder_Default(localEndpoint, clock, reporter), currentSpan, spanFactoryBuilder.build() ); }
private SpanId getSpanId(String traceId, String spanId, String parentSpanId) { return SpanId.builder() .traceId(convertToLong(traceId)) .spanId(convertToLong(spanId)) .parentId(parentSpanId == null ? null : convertToLong(parentSpanId)).build(); } }
/** * {@inheritDoc} */ @Override public Span span() { return state().getCurrentServerSpan().getSpan(); }
/** * Associates an event that explains latency with the current system time. * * @param value A short tag indicating the event, like "finagle.retry" */ public void submitAnnotation(String value) { Span span = currentSpan().get(); if (span == null) return; recorder().annotate(span, recorder().currentTimeMicroseconds(span), value); }
/** * Sets the current Trace/Span state. Using this method indicates that a parent request has decided that we should not * trace the current request. * * @see ServerTracer#setStateCurrentTrace(long, long, Long, String) * @see ServerTracer#setStateUnknown(String) */ public void setStateNoTracing() { spanAndEndpoint().state().setCurrentServerSpan(ServerSpan.NOT_SAMPLED); }
static SpanId getSpanId(String traceId, String spanId, String parentSpanId) { return SpanId.builder() .traceId(convertToLong(traceId)) .spanId(convertToLong(spanId)) .parentId(parentSpanId == null ? null : convertToLong(parentSpanId)).build(); }