Beamlens.Telemetry
(beamlens v0.3.1)
View Source
Telemetry events emitted by beamlens.
All events include a trace_id for correlating events within a single operator run.
Events follow the standard :start, :stop, :exception lifecycle pattern
used by Phoenix, Oban, and other Elixir libraries.
Event Schema
Start events include %{system_time: integer} measurement.
Stop events include %{duration: integer} measurement (native time units).
Exception events include %{duration: integer} measurement and metadata:
%{kind: :error | :throw | :exit, reason: term(), stacktrace: list()}.
LLM Events
[:beamlens, :llm, :start]- LLM call starting- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), iteration: integer, context_size: integer}
- Measurements:
[:beamlens, :llm, :stop]- LLM call completed- Measurements:
%{duration: integer} - Metadata:
%{trace_id: String.t(), iteration: integer, tool_selected: String.t(), intent: String.t(), response: struct()}
- Measurements:
[:beamlens, :llm, :exception]- LLM call failed- Measurements:
%{duration: integer} - Metadata:
%{trace_id: String.t(), iteration: integer, kind: atom(), reason: term(), stacktrace: list()}
- Measurements:
Tool Events
[:beamlens, :tool, :start]- Tool execution starting- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), iteration: integer, tool_name: String.t(), intent: String.t()}
- Measurements:
[:beamlens, :tool, :stop]- Tool execution completed- Measurements:
%{duration: integer} - Metadata:
%{trace_id: String.t(), iteration: integer, tool_name: String.t(), intent: String.t(), result: map()}
- Measurements:
[:beamlens, :tool, :exception]- Tool execution failed- Measurements:
%{duration: integer} - Metadata:
%{trace_id: String.t(), iteration: integer, tool_name: String.t(), kind: atom(), reason: term(), stacktrace: list()}
- Measurements:
Operator Events
[:beamlens, :operator, :started]- Operator server started- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom()}
- Measurements:
[:beamlens, :operator, :iteration_start]- Operator iteration starting- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), iteration: integer, operator_state: atom()}
- Measurements:
[:beamlens, :operator, :state_change]- Operator state changed- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), from: atom(), to: atom(), reason: String.t()}
- Measurements:
[:beamlens, :operator, :notification_sent]- Operator sent a notification- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), notification: Notification.t()}
- Measurements:
[:beamlens, :operator, :get_notifications]- Operator retrieved notifications- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), count: integer}
- Measurements:
[:beamlens, :operator, :take_snapshot]- Operator captured a snapshot- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), snapshot_id: String.t()}
- Measurements:
[:beamlens, :operator, :get_snapshot]- Operator retrieved a snapshot- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), snapshot_id: String.t()}
- Measurements:
[:beamlens, :operator, :get_snapshots]- Operator retrieved multiple snapshots- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), count: integer}
- Measurements:
[:beamlens, :operator, :execute_start]- Operator Lua execution starting- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), code: String.t()}
- Measurements:
[:beamlens, :operator, :execute_complete]- Operator Lua execution completed- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), code: String.t(), result: term()}
- Measurements:
[:beamlens, :operator, :execute_error]- Operator Lua execution failed- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), code: String.t(), reason: term()}
- Measurements:
[:beamlens, :operator, :wait]- Operator sleeping- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), ms: integer}
- Measurements:
[:beamlens, :operator, :think]- Operator recorded a thought- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), thought: String.t()}
- Measurements:
[:beamlens, :operator, :done]- Operator analysis completed- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t()}
- Measurements:
[:beamlens, :operator, :llm_error]- Operator LLM call failed- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), reason: term(), retry_count: integer, will_retry: boolean}
- Measurements:
[:beamlens, :operator, :loop_stopped]- Operator loop stopped normally- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), final_state: atom()}
- Measurements:
[:beamlens, :operator, :notification_failed]- Notification creation failed- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), trace_id: String.t(), reason: String.t()}
- Measurements:
[:beamlens, :operator, :unexpected_message]- GenServer received unexpected message- Measurements:
%{system_time: integer} - Metadata:
%{operator: atom(), message: String.t()}
- Measurements:
Coordinator Events
[:beamlens, :coordinator, :started]- Coordinator server started- Measurements:
%{system_time: integer} - Metadata:
%{running: boolean, notification_count: integer}
- Measurements:
[:beamlens, :coordinator, :iteration_start]- Coordinator analysis iteration starting- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), iteration: integer}
- Measurements:
[:beamlens, :coordinator, :get_notifications]- Coordinator retrieved notifications- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), status: atom(), count: integer}
- Measurements:
[:beamlens, :coordinator, :update_notification_statuses]- Coordinator updated notification statuses- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), notification_ids: list(String.t()), status: atom()}
- Measurements:
[:beamlens, :coordinator, :insight_produced]- Coordinator created an insight- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), insight: Insight.t()}
- Measurements:
[:beamlens, :coordinator, :done]- Coordinator analysis loop completed- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), has_unread: boolean, unread_count: non_neg_integer}
- Measurements:
[:beamlens, :coordinator, :loop_stopped]- Coordinator loop stopped- Measurements:
%{system_time: integer} - Metadata:
%{reason: atom()}
- Measurements:
[:beamlens, :coordinator, :llm_error]- Coordinator LLM call failed- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), reason: term()}
- Measurements:
[:beamlens, :coordinator, :unexpected_message]- GenServer received unexpected message- Measurements:
%{system_time: integer} - Metadata:
%{running: boolean, notification_count: integer, message: String.t()}
- Measurements:
[:beamlens, :coordinator, :invoke_operators]- Coordinator invoked operators- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), skills: list(atom())}
- Measurements:
[:beamlens, :coordinator, :message_operator]- Coordinator messaged a running operator- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), skill: atom()}
- Measurements:
[:beamlens, :coordinator, :get_operator_statuses]- Coordinator retrieved operator statuses- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t()}
- Measurements:
[:beamlens, :coordinator, :wait]- Coordinator sleeping- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), ms: integer}
- Measurements:
[:beamlens, :coordinator, :think]- Coordinator recorded a thought- Measurements:
%{system_time: integer} - Metadata:
%{trace_id: String.t(), thought: String.t()}
- Measurements:
[:beamlens, :coordinator, :operator_notification_received]- Notification received from running operator- Measurements:
%{system_time: integer} - Metadata:
%{notification_id: String.t(), operator_pid: pid()}
- Measurements:
[:beamlens, :coordinator, :operator_complete]- Operator completed- Measurements:
%{system_time: integer} - Metadata:
%{skill: atom(), result: map()}
- Measurements:
[:beamlens, :coordinator, :operator_crashed]- Operator crashed- Measurements:
%{system_time: integer} - Metadata:
%{skill: atom(), reason: term()}
- Measurements:
[:beamlens, :coordinator, :max_iterations_reached]- Coordinator reached max iterations- Measurements:
%{system_time: integer} - Metadata:
%{iteration: integer}
- Measurements:
Compaction Events
[:beamlens, :compaction, :start]- Context compaction starting- Measurements:
%{system_time: integer, message_count: integer} - Metadata:
%{trace_id: String.t(), iteration: integer, strategy: module(), config: map()}
- Measurements:
[:beamlens, :compaction, :stop]- Context compaction completed- Measurements:
%{system_time: integer, message_count: integer} - Metadata:
%{trace_id: String.t(), iteration: integer}
- Measurements:
Example Handler
:telemetry.attach(
"beamlens-notifications",
[:beamlens, :operator, :notification_sent],
fn _event, _measurements, metadata, _config ->
Logger.warning("beamlens notification: #{metadata.notification.observation}")
end,
nil
)Attaching to All Events
:telemetry.attach_many(
"my-handler",
Beamlens.Telemetry.event_names(),
&MyHandler.handle_event/4,
nil
)
Summary
Functions
Attaches a default logging handler to all beamlens telemetry events.
Detaches the default logging handler.
Emits a tool exception event with duration and exception details.
Emits a tool start event.
Emits a tool stop event with the tool result and duration.
Returns all telemetry event names that can be emitted.
Generates a unique trace ID for an operator run.
Executes a tool with telemetry span events.
Functions
Attaches a default logging handler to all beamlens telemetry events.
Options
:level- Log level to use (default::debug)
Detaches the default logging handler.
Emits a tool exception event with duration and exception details.
start_time should be captured via System.monotonic_time() before tool execution.
kind is the exception type (:error, :throw, or :exit).
stacktrace is the exception stacktrace.
Emits a tool start event.
Emits a tool stop event with the tool result and duration.
start_time should be captured via System.monotonic_time() before tool execution.
Returns all telemetry event names that can be emitted.
Generates a unique trace ID for an operator run.
Executes a tool with telemetry span events.
Emits :start, :stop, and :exception events for the tool execution.