AI observability boundary for telemetry events and spans.
This module centralizes:
- Canonical AI telemetry event names
- Required AI metadata/measurement normalization
- Feature-gated event emission
- Span lifecycle wrappers that honor AI observability config
- Sensitive value redaction helpers for telemetry payloads
- Bounded telemetry and transport-safe payload shaping
Summary
Functions
Emits an AI telemetry event when enabled in obs_cfg.
Ensures required AI measurement keys are present with 0 defaults.
Ensures required AI metadata keys are present with nil defaults.
Finishes a span started by start_span/3.
Finishes a span with error details.
Builds an LLM telemetry event path under [:jido, :ai, :llm, ...].
Builds a structured output telemetry event path under [:jido, :ai, :output, ...].
Builds a request telemetry event path under [:jido, :ai, :request, ...].
Sanitizes arbitrary payloads for a specific boundary profile.
Redacts sensitive keys recursively for telemetry-safe payloads.
Sanitizes event metadata before it crosses the telemetry boundary.
Sanitizes a public/tool payload into bounded JSON-safe data.
Starts a telemetry span when AI telemetry is enabled.
Builds a strategy telemetry event path under [:jido, :ai, :strategy, strategy, ...].
Builds a tool telemetry event path under [:jido, :ai, :tool, ...].
Builds a tool execution telemetry event path for executor internals.
Types
@type event_name() :: [atom()]
@type feature_gate() :: :llm_deltas
@type measurements() :: map()
@type metadata() :: map()
@type obs_cfg() :: map() | nil
@type sanitize_profile() :: Jido.AI.Observe.Sanitize.profile()
@type span_ctx() :: Jido.Observe.span_ctx() | :noop
Functions
@spec emit(obs_cfg(), event_name(), measurements(), metadata(), keyword()) :: :ok
Emits an AI telemetry event when enabled in obs_cfg.
Supports optional feature gates via opts:
feature_gate: :llm_deltas
Ensures required AI measurement keys are present with 0 defaults.
Ensures required AI metadata keys are present with nil defaults.
@spec finish_span(span_ctx(), measurements()) :: :ok
Finishes a span started by start_span/3.
Finishes a span with error details.
@spec llm(atom()) :: event_name()
Builds an LLM telemetry event path under [:jido, :ai, :llm, ...].
@spec output(atom()) :: event_name()
Builds a structured output telemetry event path under [:jido, :ai, :output, ...].
@spec request(atom()) :: event_name()
Builds a request telemetry event path under [:jido, :ai, :request, ...].
@spec sanitize(term(), sanitize_profile(), keyword()) :: term()
Sanitizes arbitrary payloads for a specific boundary profile.
The :telemetry profile keeps metadata low-cardinality by redacting
sensitive keys, truncating large values, and summarizing payload-shaped
fields such as results and provider responses.
The :transport profile preserves more payload detail while converting
arbitrary terms into bounded JSON-safe data.
Redacts sensitive keys recursively for telemetry-safe payloads.
Sanitizes event metadata before it crosses the telemetry boundary.
Sanitizes a public/tool payload into bounded JSON-safe data.
@spec start_span(obs_cfg(), event_name(), metadata()) :: span_ctx()
Starts a telemetry span when AI telemetry is enabled.
Returns :noop when telemetry is disabled or event prefix is invalid.
@spec strategy(atom(), atom()) :: event_name()
Builds a strategy telemetry event path under [:jido, :ai, :strategy, strategy, ...].
@spec tool(atom()) :: event_name()
Builds a tool telemetry event path under [:jido, :ai, :tool, ...].
@spec tool_execute(atom()) :: event_name()
Builds a tool execution telemetry event path for executor internals.