Jido.Telemetry (Jido v2.0.0-rc.1)
View SourceHandles telemetry events for Jido Agent and Strategy operations.
This module provides telemetry integration for agent command execution and strategy lifecycle events. It tracks execution time, success/failure rates, and provides debugging insights.
Events
Agent Events
[:jido, :agent, :cmd, :start]- Agent command execution started[:jido, :agent, :cmd, :stop]- Agent command execution completed[:jido, :agent, :cmd, :exception]- Agent command execution failed
AgentServer Events
[:jido, :agent_server, :signal, :start]- Signal processing started[:jido, :agent_server, :signal, :stop]- Signal processing completed[:jido, :agent_server, :signal, :exception]- Signal processing failed[:jido, :agent_server, :directive, :start]- Directive execution started[:jido, :agent_server, :directive, :stop]- Directive execution completed[:jido, :agent_server, :directive, :exception]- Directive execution failed[:jido, :agent_server, :queue, :overflow]- Directive queue overflow
Strategy Events
[:jido, :agent, :strategy, :init, :start]- Strategy initialization started[:jido, :agent, :strategy, :init, :stop]- Strategy initialization completed[:jido, :agent, :strategy, :init, :exception]- Strategy initialization failed[:jido, :agent, :strategy, :cmd, :start]- Strategy command execution started[:jido, :agent, :strategy, :cmd, :stop]- Strategy command execution completed[:jido, :agent, :strategy, :cmd, :exception]- Strategy command execution failed[:jido, :agent, :strategy, :tick, :start]- Strategy tick started[:jido, :agent, :strategy, :tick, :stop]- Strategy tick completed[:jido, :agent, :strategy, :tick, :exception]- Strategy tick failed
Metadata
All events include metadata about the agent, action, and strategy:
:agent_id- The agent's unique identifier:agent_module- The agent module name:strategy- The strategy module name:action- The action being executed (for cmd events):directive_count- Number of directives produced (for stop events)
Summary
Functions
Returns a specification to start this module under a supervisor.
Handles telemetry events for agent and strategy operations.
Executes an agent command while emitting telemetry events.
Executes a strategy operation while emitting telemetry events.
Starts the telemetry handler.
Types
@type event_name() :: [atom(), ...]
Supported telemetry event names.
@type measurements() :: %{ optional(:system_time) => integer(), optional(:duration) => integer(), required(atom()) => term() }
Telemetry measurements map.
@type metadata() :: %{ optional(:agent_id) => String.t(), optional(:agent_module) => module(), optional(:strategy) => module(), optional(:action) => term(), optional(:directive_count) => non_neg_integer(), optional(:error) => term(), required(atom()) => term() }
Telemetry metadata map.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec handle_event(event_name(), measurements(), metadata(), config :: term()) :: :ok
Handles telemetry events for agent and strategy operations.
@spec span_agent_cmd(Jido.Agent.t(), term(), (-> result)) :: result when result: term()
Executes an agent command while emitting telemetry events.
Examples
Jido.Telemetry.span_agent_cmd(agent, action, fn ->
# Execute command logic
{updated_agent, directives}
end)
@spec span_strategy(Jido.Agent.t(), :init | :cmd | :tick, module(), (-> result)) :: result when result: term()
Executes a strategy operation while emitting telemetry events.
Examples
Jido.Telemetry.span_strategy(agent, :init, strategy_module, fn ->
# Execute strategy logic
{updated_agent, directives}
end)
@spec start_link(keyword()) :: GenServer.on_start()
Starts the telemetry handler.