/** * Gets the Trace/Span context. * * @return Trace/Span context. Can be <code>null</code> in case we did not get any context in request. */ @Nullable public abstract Span getSpan();
/** * Indicates if we need to sample this request or not. * * @return <code>true</code> in case we should sample this request, <code>false</code> in case we should not sample this * request or <code>null</code> in case we did not get any indication about sampling this request. In this case * new client requests should decide about sampling or not. */ @Nullable public abstract Boolean getSample();
/** * Indicates if we need to sample this request or not. * * @return <code>true</code> in case we should sample this request, <code>false</code> in case we should not sample this * request or <code>null</code> in case we did not get any indication about sampling this request. In this case * new client requests should decide about sampling or not. */ @Nullable public abstract Boolean getSample();
@Nullable @Override Span currentLocalSpan() { return currentLocalSpan; }
/** * Gets the Span for the client request that was started as part of current request. * <p/> * Should be thread-aware to support multiple parallel requests. * * @return Client request span for current thread. */ @Nullable Span getCurrentClientSpan();
/** * Gets the Span for the local request that was started as part of current request. * <p/> * Should be thread-aware to support multiple parallel requests. * * @return Local request span for current thread. */ @Nullable Span getCurrentLocalSpan();
/** * Returns the upstream sampling decision or null to make one here. * * @see SpanId#sampled() */ @Nullable public abstract Boolean getSample();
@Nullable @Override public Span getSpan() { return getSpan; }
/** * Enrich the request with the Spanid so we pass the state to the * service we are calling. * * @param spanId Nullable span id. If null we don't need to trace request and you * should pass an indication along with the request that indicates we won't trace this request. */ void addSpanIdToRequest(@Nullable SpanId spanId);
/** * Provides the remote server address information for additional tracking. * * Can be useful when communicating with non-traced services by adding server address to span * i.e. {@link com.twitter.zipkin.gen.zipkinCoreConstants#SERVER_ADDR} * * @return request's target server endpoint information */ @Nullable Endpoint serverAddress(); }
/** * {@inheritDoc} */ @Override @Nullable public Span getCurrentClientSpan() { return currentClientSpan.get(); }
@Override public void setCurrentLocalSpan(@Nullable Span span) { if (span == null) { currentLocalSpan.remove(); } else { currentLocalSpan.set(span); } } }
@Override public void setCurrentServerSpan(@Nullable ServerSpan span) { if (span == null) { currentServerSpan.remove(); } else { currentServerSpan.set(span); } }
/** * Get parent span id. * * @return Parent span id. Can be <code>null</code>. * @deprecated use {@link #nullableParentId()} */ @Deprecated @Nullable public Long getParentSpanId() { return nullableParentId(); }
/** * Get parent span id. * * @return Parent span id. Can be <code>null</code>. * @deprecated use {@link #nullableParentId()} */ @Deprecated @Nullable public Long getParentSpanId() { return nullableParentId(); }
/** * Should we sample this request or not? True means sample, false means don't, null means we defer * decision to someone further down in the stack. */ @Nullable public final Boolean sampled() { if (debug()) return true; return (flags & FLAG_SAMPLING_SET) == FLAG_SAMPLING_SET ? (flags & FLAG_SAMPLED) == FLAG_SAMPLED : null; }
BinaryAnnotation(String key, byte[] value, AnnotationType type, @Nullable Endpoint host) { this.key = checkNotBlank(key, "Null or blank key"); this.value = checkNotNull(value, "Null value"); this.type = type; this.host = host; }
/** * Creates a new span id. * * @param traceId Trace Id. * @param spanId Span Id. * @param parentSpanId Nullable parent span id. * @deprecated Please use {@link SpanId.Builder} */ @Deprecated public static SpanId create(long traceId, long spanId, @Nullable Long parentSpanId) { return SpanId.builder().traceId(traceId).parentId(parentSpanId).spanId(spanId).build(); }
/** * Creates a new span id. * * @param traceId Trace Id. * @param spanId Span Id. * @param parentSpanId Nullable parent span id. * @deprecated Please use {@link SpanId.Builder} */ @Deprecated public static SpanId create(long traceId, long spanId, @Nullable Long parentSpanId) { return SpanId.builder().traceId(traceId).parentId(parentSpanId).spanId(spanId).build(); }
/** * @deprecated since 3.15 use {@link #setStateCurrentTrace(SpanId, String)} */ @Deprecated public void setStateCurrentTrace(long traceId, long spanId, @Nullable Long parentSpanId, String name) { SpanId context = SpanId.builder().traceId(traceId).spanId(spanId).parentId(parentSpanId).build(); setStateCurrentTrace(context, name); }