Interface LLMObsSpan

All Known Implementing Classes:
NoOpLLMObsSpan

public interface LLMObsSpan
This interface represent an individual LLM Obs span.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Annotate the span with a throwable
    void
    annotateIO(String inputData, String outputData)
    Annotate the span with inputs and outputs
    void
    annotateIO(List<LLMObs.LLMMessage> inputMessages, List<LLMObs.LLMMessage> outputMessages)
    Annotate the span with inputs and outputs for LLM spans
    void
    Finishes (closes) a span
    long
    Gets the SpanId.
    Gets the TraceId of the span's trace.
    void
    setError(boolean error)
    Annotate the span to indicate that an error occurred
    void
    setErrorMessage(String errorMessage)
    Annotate the span with an error message
    void
    Annotate the span with metadata
    void
    setMetric(CharSequence key, double value)
    Annotate the span with a single metric key value pair for the span’s context (number of tokens document length, etc).
    void
    setMetric(CharSequence key, int value)
    Annotate the span with a single metric key value pair for the span’s context (number of tokens document length, etc).
    void
    setMetric(CharSequence key, long value)
    Annotate the span with a single metric key value pair for the span’s context (number of tokens document length, etc).
    void
    Annotate the span with metrics
    void
    setTag(String key, boolean value)
    Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
    void
    setTag(String key, double value)
    Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
    void
    setTag(String key, int value)
    Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
    void
    setTag(String key, long value)
    Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
    void
    setTag(String key, String value)
    Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
    void
    Annotate the span with tags
  • Method Details

    • annotateIO

      void annotateIO(List<LLMObs.LLMMessage> inputMessages, List<LLMObs.LLMMessage> outputMessages)
      Annotate the span with inputs and outputs for LLM spans
      Parameters:
      inputMessages - The input messages of the span in the form of a list
      outputMessages - The output messages of the span in the form of a list
    • annotateIO

      void annotateIO(String inputData, String outputData)
      Annotate the span with inputs and outputs
      Parameters:
      inputData - The input data of the span in the form of a string
      outputData - The output data of the span in the form of a string
    • setMetadata

      void setMetadata(Map<String,Object> metadata)
      Annotate the span with metadata
      Parameters:
      metadata - A map of JSON serializable key-value pairs that contains metadata information relevant to the input or output operation described by the span
    • setMetrics

      void setMetrics(Map<String,Number> metrics)
      Annotate the span with metrics
      Parameters:
      metrics - A map of JSON serializable keys and numeric values that users can add as metrics relevant to the operation described by the span (input_tokens, output_tokens, total_tokens, etc.).
    • setMetric

      void setMetric(CharSequence key, int value)
      Annotate the span with a single metric key value pair for the span’s context (number of tokens document length, etc).
      Parameters:
      key - the name of the metric
      value - the value of the metric
    • setMetric

      void setMetric(CharSequence key, long value)
      Annotate the span with a single metric key value pair for the span’s context (number of tokens document length, etc).
      Parameters:
      key - the name of the metric
      value - the value of the metric
    • setMetric

      void setMetric(CharSequence key, double value)
      Annotate the span with a single metric key value pair for the span’s context (number of tokens document length, etc).
      Parameters:
      key - the name of the metric
      value - the value of the metric
    • setTags

      void setTags(Map<String,Object> tags)
      Annotate the span with tags
      Parameters:
      tags - An map of JSON serializable key-value pairs that users can add as tags regarding the span’s context (session, environment, system, versioning, etc.).
    • setTag

      void setTag(String key, String value)
      Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
      Parameters:
      key - the key of the tag
      value - the value of the tag
    • setTag

      void setTag(String key, boolean value)
      Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
      Parameters:
      key - the key of the tag
      value - the value of the tag
    • setTag

      void setTag(String key, int value)
      Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
      Parameters:
      key - the key of the tag
      value - the value of the tag
    • setTag

      void setTag(String key, long value)
      Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
      Parameters:
      key - the key of the tag
      value - the value of the tag
    • setTag

      void setTag(String key, double value)
      Annotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).
      Parameters:
      key - the key of the tag
      value - the value of the tag
    • setError

      void setError(boolean error)
      Annotate the span to indicate that an error occurred
      Parameters:
      error - whether an error occurred
    • setErrorMessage

      void setErrorMessage(String errorMessage)
      Annotate the span with an error message
      Parameters:
      errorMessage - the message of the error
    • addThrowable

      void addThrowable(Throwable throwable)
      Annotate the span with a throwable
      Parameters:
      throwable - the errored throwable
    • finish

      void finish()
      Finishes (closes) a span
    • getTraceId

      DDTraceId getTraceId()
      Gets the TraceId of the span's trace.
      Returns:
      The TraceId of the span's trace, or DDTraceId.ZERO if not set.
    • getSpanId

      long getSpanId()
      Gets the SpanId.
      Returns:
      The span identifier.