001package io.prometheus.metrics.tracer.common;
002
003import io.prometheus.metrics.annotations.StableApi;
004import javax.annotation.Nullable;
005
006@StableApi
007public interface SpanContext {
008
009  String EXEMPLAR_ATTRIBUTE_NAME = "exemplar";
010  String EXEMPLAR_ATTRIBUTE_VALUE = "true";
011
012  /**
013   * @return the current trace id, or {@code null} if this call is not happening within a span
014   *     context.
015   */
016  @Nullable
017  String getCurrentTraceId();
018
019  /**
020   * @return the current span id, or {@code null} if this call is not happening within a span
021   *     context.
022   */
023  @Nullable
024  String getCurrentSpanId();
025
026  /**
027   * @return the state of the current Span. If this value is false a component before in the chain
028   *     take the decision to not record it. Subsequent calling service have to respect this value
029   *     in order not to have partial TraceID with only some Span in it. This value is important to
030   *     be sure to choose a recorded Trace in Exemplar sampling process
031   */
032  boolean isCurrentSpanSampled();
033
034  void markCurrentSpanAsExemplar();
035}