Package com.ants.platform.tracing
Class AntsObservation
java.lang.Object
com.ants.platform.tracing.AntsObservation
- Direct Known Subclasses:
AntsGeneration
A thin, fluent wrapper over an OpenTelemetry
Span that writes the
Ants-specific attributes the backend maps to observations.
Mirrors the JS AntsPlatformSpan / Python AntsPlatformSpan
wrappers. Setters write attributes immediately and return this for
chaining. Specialized generation behaviour lives in AntsGeneration.
Create observations via Ants.startObservation(java.lang.String) /
Ants.startActiveObservation(java.lang.String, com.ants.platform.tracing.ObservationType, java.util.function.Consumer<com.ants.platform.tracing.AntsObservation>), or nest them with
startChild(String, ObservationType).
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidend()Ends the observation at the current time.voidEnds the observation at an explicit instant.id()The observation id (16-char hex span id).Sets the observation input (serialized to JSON).Sets the observation level (e.g.Sets observation metadata.io.opentelemetry.api.trace.SpanotelSpan()The underlying OpenTelemetry span.Sets the observation output (serialized to JSON).recordError(Throwable error) Records an error on this observation: sets the OTel status to ERROR,level=ERRORand a status message, and records the exception.startChild(String name, ObservationType childType) Starts a child observation parented to this one.startChildGeneration(String name) Starts a childgenerationparented to this observation.statusMessage(String statusMessage) Sets a human-readable status message (typically withlevel("ERROR")).traceId()The trace id (32-char hex) this observation belongs to.type()The observation type.updateTrace(TraceAttributes attrs) Updates trace-level attributes on this observation's span.Sets a version identifier for the code/model being traced.
-
Field Details
-
otelSpan
protected final io.opentelemetry.api.trace.Span otelSpan
-
-
Method Details
-
otelSpan
public io.opentelemetry.api.trace.Span otelSpan()The underlying OpenTelemetry span. -
traceId
The trace id (32-char hex) this observation belongs to. -
id
The observation id (16-char hex span id). -
type
The observation type. -
input
Sets the observation input (serialized to JSON). -
output
Sets the observation output (serialized to JSON). -
metadata
Sets 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. -
level
Sets the observation level (e.g.DEBUG,DEFAULT,WARNING,ERROR). -
statusMessage
Sets a human-readable status message (typically withlevel("ERROR")). -
version
Sets a version identifier for the code/model being traced. -
recordError
Records an error on this observation: sets the OTel status to ERROR,level=ERRORand a status message, and records the exception. -
updateTrace
Updates trace-level attributes on this observation's span. -
startChild
Starts a child observation parented to this one. The child nests under this span regardless of the current OTel context. -
startChildGeneration
Starts a childgenerationparented to this observation. -
end
public void end()Ends the observation at the current time. -
end
Ends the observation at an explicit instant.
-