adk_observability (erlang_adk v0.7.0)
View SourceCorrelated telemetry and safe structured event/log envelopes.
The module has no mandatory OpenTelemetry dependency. It emits ordinary telemetry events carrying stable correlation metadata and can deliver the same JSON-safe envelope to optional bounded exporters. Prompt, response, tool arguments, and other content are omitted unless capture is explicitly enabled; authentication material is pruned in either mode.
Summary
Functions
Create a correlated child span context.
Decode a persisted envelope. Unknown schema versions are rejected.
Deliver through either the compatibility synchronous path or the bounded supervised asynchronous bus.
Emit a connected telemetry event and return its structured envelope.
Verify and return the canonical JSON-safe envelope.
Deliver one already-safe envelope to bounded exporters in list order.
Finish an operation span and update bounded low-cardinality metrics.
Continue a valid inbound W3C trace with a fresh local span.
Inject this context into outbound HTTP-style headers.
Build a root correlation context.
Surface an exporter failure which happened after an operation had already completed. Only structural tags and correlation IDs are emitted; the untrusted exporter reason is never forwarded. This diagnostic is deliberately separate from the operation result so callers cannot replay a successful model/tool side effect merely because span delivery failed.
Start a real operation span at the execution boundary.
Validate exporter descriptors at Runner construction time. Callback execution still revalidates the immutable descriptors so a forged Runner term cannot bypass the boundary.
Types
Functions
Create a correlated child span context.
Trace/run/session identity is inherited. The parent's span ID becomes the child parent ID. Additional agent/model/tool/call fields may be overridden.
Decode a persisted envelope. Unknown schema versions are rejected.
Deliver through either the compatibility synchronous path or the bounded supervised asynchronous bus.
Async admission is explicit: a full queue is returned to the caller and is also visible in bus counters. failure_policy controls whether admission failure is reported (closed) or converted into a structural dropped result (open).
Emit a connected telemetry event and return its structured envelope.
Options are attributes, capture_content (default false), and content. Even when capture is enabled, secret-bearing keys are removed before either telemetry handlers or exporters can see them.
Verify and return the canonical JSON-safe envelope.
Deliver one already-safe envelope to bounded exporters in list order.
Exporter descriptors use id, module, optional config, timeout_ms, max_heap_words, and failure_policy (open by default). Fail-open exporters report failure and allow later exporters to run. Fail-closed stops immediately with a typed error.
Finish an operation span and update bounded low-cardinality metrics.
Continue a valid inbound W3C trace with a fresh local span.
This function validates wire syntax but deliberately does not decide whether the remote sampling bit should be trusted. Network boundaries may clear trace_flags or start a new trace before calling it.
Inject this context into outbound HTTP-style headers.
-spec new_context() -> {ok, context()}.
Build a root correlation context.
Known identity fields are copied explicitly; unknown safe fields are placed below attributes. Binary input is never converted into an atom.
Surface an exporter failure which happened after an operation had already completed. Only structural tags and correlation IDs are emitted; the untrusted exporter reason is never forwarded. This diagnostic is deliberately separate from the operation result so callers cannot replay a successful model/tool side effect merely because span delivery failed.
-spec schema_version() -> pos_integer().
-spec start_span(atom() | binary(), atom() | binary(), context(), map(), map()) -> {ok, map()} | {error, term()}.
Start a real operation span at the execution boundary.
Details is mapped through the pinned metadata-only GenAI convention; it cannot inject prompt/output content. The returned handle carries monotonic timing and must be finished exactly once by the operation owner.
Validate exporter descriptors at Runner construction time. Callback execution still revalidates the immutable descriptors so a forged Runner term cannot bypass the boundary.