Package com.ants.platform.tracing
Class AntsGeneration
java.lang.Object
com.ants.platform.tracing.AntsObservation
com.ants.platform.tracing.AntsGeneration
Specialized
AntsObservation for LLM generations. Adds model, model
parameters, token usage, cost, and prompt attributes.
Report usage(java.util.Map<java.lang.String, ? extends java.lang.Number>) together with model(java.lang.String); the backend computes
cost server-side from the model's price book, so cost(java.util.Map<java.lang.String, ? extends java.lang.Number>) is optional.
-
Field Summary
Fields inherited from class com.ants.platform.tracing.AntsObservation
otelSpan -
Method Summary
Modifier and TypeMethodDescriptioncompletionStartTime(Instant completionStartTime) Timestamp when the model began streaming the completion.Cost breakdown (optional; the backend computes cost from model + usage).Sets the observation input (serialized to JSON).Sets the observation level (e.g.Sets observation metadata.Name of the model used (e.g.modelParameters(Map<String, ?> params) Model invocation parameters (temperature, max_tokens, ...), serialized to JSON.Sets the observation output (serialized to JSON).Links this generation to a managed prompt by name + version.recordError(Throwable error) Records an error on this observation: sets the OTel status to ERROR,level=ERRORand a status message, and records the exception.statusMessage(String statusMessage) Sets a human-readable status message (typically withlevel("ERROR")).updateTrace(TraceAttributes attrs) Updates trace-level attributes on this observation's span.usage(long inputTokens, long outputTokens) Convenience: report input/output token counts; total is their sum.usage(long inputTokens, long outputTokens, long totalTokens) Convenience: report input/output/total token counts.Token usage as an arbitrary map (e.g.Sets a version identifier for the code/model being traced.Methods inherited from class com.ants.platform.tracing.AntsObservation
end, end, id, otelSpan, startChild, startChildGeneration, traceId, type
-
Method Details
-
model
Name of the model used (e.g.gpt-4o-mini); drives server-side cost. -
modelParameters
Model invocation parameters (temperature, max_tokens, ...), serialized to JSON. -
usage
Token usage as an arbitrary map (e.g.{input, output, total}). -
usage
Convenience: report input/output token counts; total is their sum. -
usage
Convenience: report input/output/total token counts. -
cost
Cost breakdown (optional; the backend computes cost from model + usage). -
completionStartTime
Timestamp when the model began streaming the completion. -
prompt
Links this generation to a managed prompt by name + version. -
input
Description copied from class:AntsObservationSets the observation input (serialized to JSON).- Overrides:
inputin classAntsObservation
-
output
Description copied from class:AntsObservationSets the observation output (serialized to JSON).- Overrides:
outputin classAntsObservation
-
metadata
Description copied from class:AntsObservationSets observation metadata. A map is flattened to one attribute per top-level key (ants-platform.observation.metadata.<key>), matching the other SDKs; anything else is serialized whole.- Overrides:
metadatain classAntsObservation
-
level
Description copied from class:AntsObservationSets the observation level (e.g.DEBUG,DEFAULT,WARNING,ERROR).- Overrides:
levelin classAntsObservation
-
statusMessage
Description copied from class:AntsObservationSets a human-readable status message (typically withlevel("ERROR")).- Overrides:
statusMessagein classAntsObservation
-
version
Description copied from class:AntsObservationSets a version identifier for the code/model being traced.- Overrides:
versionin classAntsObservation
-
recordError
Description copied from class:AntsObservationRecords an error on this observation: sets the OTel status to ERROR,level=ERRORand a status message, and records the exception.- Overrides:
recordErrorin classAntsObservation
-
updateTrace
Description copied from class:AntsObservationUpdates trace-level attributes on this observation's span.- Overrides:
updateTracein classAntsObservation
-