Package datadog.trace.api.llmobs
Interface LLMObsSpan
- All Known Implementing Classes:
NoOpLLMObsSpan
public interface LLMObsSpan
This interface represent an individual LLM Obs span.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddThrowable(Throwable throwable) Annotate the span with a throwablevoidannotateIO(String inputData, String outputData) Annotate the span with inputs and outputsvoidannotateIO(List<LLMObs.LLMMessage> inputMessages, List<LLMObs.LLMMessage> outputMessages) Annotate the span with inputs and outputs for LLM spansvoidfinish()Finishes (closes) a spanlongGets the SpanId.Gets the TraceId of the span's trace.voidsetError(boolean error) Annotate the span to indicate that an error occurredvoidsetErrorMessage(String errorMessage) Annotate the span with an error messagevoidsetMetadata(Map<String, Object> metadata) Annotate the span with metadatavoidsetMetric(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).voidsetMetric(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).voidsetMetric(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).voidsetMetrics(Map<String, Number> metrics) Annotate the span with metricsvoidAnnotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).voidAnnotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).voidAnnotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).voidAnnotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).voidAnnotate the span with a single tag key value pair as a tag regarding the span’s context (session, environment, system, versioning, etc.).voidAnnotate the span with tags
-
Method Details
-
annotateIO
Annotate the span with inputs and outputs for LLM spans- Parameters:
inputMessages- The input messages of the span in the form of a listoutputMessages- The output messages of the span in the form of a list
-
annotateIO
Annotate the span with inputs and outputs- Parameters:
inputData- The input data of the span in the form of a stringoutputData- The output data of the span in the form of a string
-
setMetadata
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
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
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 metricvalue- the value of the metric
-
setMetric
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 metricvalue- the value of the metric
-
setMetric
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 metricvalue- the value of the metric
-
setTags
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
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 tagvalue- the value of the tag
-
setTag
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 tagvalue- the value of the tag
-
setTag
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 tagvalue- the value of the tag
-
setTag
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 tagvalue- the value of the tag
-
setTag
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 tagvalue- 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
Annotate the span with an error message- Parameters:
errorMessage- the message of the error
-
addThrowable
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.ZEROif not set.
-
getSpanId
long getSpanId()Gets the SpanId.- Returns:
- The span identifier.
-