Octoroom.Agent.Telemetry (octoroom_agents v0.1.0)

Copy Markdown View Source

The :telemetry events octoroom_agents emits.

Durations on span events (:start / :first_output / :stop / :exception) are in Erlang native time units, matching :telemetry.span/3, Telemetry.Metrics (unit: {:native, :millisecond}), and OpenTelemetry bridges. [:octoroom_agent, :turn, :latency] reports milliseconds with explicit *_ms keys.

When run under Octoroom.Agent.Worker, metadata includes room_id, agent_id, and (for front ends) input.

Async stages (Octoroom.Agent.Pipeline.Core)

Every {:async, key, fun} (and {:async, key, fun, meta}) effect emitted by a processor — including :llm, :tts, :decisions, :tools, :transcriber, and custom stages — is wrapped in a lifecycle span so every :start closes with a matching :stop or :exception:

  • [:octoroom_agent, :processor, :async, :start]: measurements system_time, monotonic_time. Metadata: processor (stage name), module, task (low-cardinality atom: e.g. :reply, :speak, :evaluate, :run, :transcribe), key, task_id, generation, uninterruptible, optional trigger (triggering frame module), and stage-specific fields (provider, model, voice, chars, modality, audio_ms, sync_tools, async_tools, call_count, turn_id, ...).
  • [:octoroom_agent, :processor, :async, :first_output]: emitted once per streaming task when its handle_async/3 pushes its first output frame (TTFT for :llm, TTFB for :tts). Measurements duration, monotonic_time; metadata adds frame (pushed frame module).
  • [:octoroom_agent, :processor, :async, :stop]: measurements duration, monotonic_time, outputs (count of frames pushed during streaming), and optional first_output_duration (native time to first pushed frame, present on streaming tasks that emitted output). Metadata adds status (:ok, :error, :cancelled, :interrupted, or :terminated) and reason when status is :error or :terminated.
  • [:octoroom_agent, :processor, :async, :exception]: the task crashed or died. Measurements duration, monotonic_time, outputs, optional first_output_duration; metadata adds kind (:error, :exit, :throw) and reason.

Tools (Octoroom.Agent.ToolDispatcher)

  • [:octoroom_agent, :tool, :call, :start | :stop | :exception]: standard :telemetry.span/3 around each individual tool handler invocation (both blocking and non-blocking, across cascaded, half-cascaded, Gemini Live, and OpenAI Live). Metadata: room_id, agent_id, tool, call_id, and on :stop, result (:ok, :error, or :unknown).

Pipeline & synchronous frames (Octoroom.Agent.Pipeline.Core)

  • [:octoroom_agent, :pipeline, :init]: measurements stages; metadata stages (list of stage names).
  • [:octoroom_agent, :pipeline, :interruption]: measurements killed_tasks, dropped_frames; metadata generation.
  • [:octoroom_agent, :processor, :frame, :start | :stop | :exception]: synchronous handle_frame/3 execution for non-audio frames (InputAudio and OutputAudio are excluded). Measurements duration (on :stop and :exception); metadata processor, frame, generation.

Live speech-to-speech (OpenAILive, GeminiLive)

  • [:octoroom_agent, :live, :session]: session lifecycle events (event: :started, :paused, :resumed, :disconnected, :closed, :error). Includes duration_ms on :started (connect time). Metadata: room_id, agent_id, provider (:openai | :gemini), model, voice, transport (:webrtc | :websocket), event, optional reason.
  • [:octoroom_agent, :live, :response, :start | :first_audio | :stop]: per spoken reply from a speech-to-speech model. :stop includes duration (native), duration_ms, audio_ms (length of spoken audio), outputs (audio chunk count), and optional response_latency_ms (user turn/transcript end to first audio). Metadata: room_id, agent_id, provider, model, voice, transport, status (:ok | :interrupted | :error), speaker, typed, user_text, assistant_text.

Turns (Octoroom.Agent.Worker)

  • [:octoroom_agent, :turn, :decided]: emitted when a front end finishes a turn (or a user types one) and the gate decides :reply, :wait, or :listen. Measurements speech_to_decided_ms, system_time, monotonic_time, and optional decision_ms. Metadata: room_id, agent_id, input, speaker, text, outcome, why, decision, stt_provider, stt_model.
  • [:octoroom_agent, :turn, :floor_wait]: emitted when a :wait turn either starts replying (outcome: :replied) or yields because someone else spoke (outcome: :yielded). Measurements duration_ms, system_time, monotonic_time; metadata room_id, agent_id, input, speaker, outcome.
  • [:octoroom_agent, :turn, :latency]: emitted when a reply's first audio reaches the outlet. Measurements transcript_ms, audio_ms, wait_ms, processing_ms (audio_ms - wait_ms), stt_and_decision_ms, and optional llm_ms (ms since the speaker's VAD speech end). Metadata: room_id, agent_id, turn_id, input, speaker, stt_provider, stt_model.

Summary

Functions

Logs one line per completed async stage, tool call, and turn latency

Detaches the handler attach_default_logger/1 attached.

Every event name above, for :telemetry.attach_many/4.

Functions

attach_default_logger(opts \\ [])

Logs one line per completed async stage, tool call, and turn latency:

[info] Octoroom.Agent room-1/assistant llm:reply ok in 412 ms (first 148 ms, 12 outputs, google/gemini-3.5-flash)
[info] Octoroom.Agent room-1/assistant tts:speak ok in 305 ms (first 112 ms, 8 outputs, inworld/inworld-tts-2)
[info] Octoroom.Agent room-1/assistant tool whoami ok in 4 ms
[info] Octoroom.Agent room-1/assistant turn latency: transcript 320 ms, llm 510 ms, audio 680 ms

Options: :level (default :info). Call once in your application's start/2; detach_default_logger/0 undoes it.

detach_default_logger()

Detaches the handler attach_default_logger/1 attached.

events()

Every event name above, for :telemetry.attach_many/4.