View Source SwarmEx.Telemetry (SwarmEx v0.2.0)

Telemetry integration for SwarmEx. Provides comprehensive metrics and event tracking for agent activities.

Event Categories

Agent Lifecycle Events

  • [:swarm_ex, :agent, :init] - Agent initialization

    • Measurement: :system_time
    • Metadata: :agent_id, :network_id, :correlation_id
  • [:swarm_ex, :agent, :terminate] - Agent termination

    • Measurement: :system_time, :uptime
    • Metadata: :agent_id, :network_id, :correlation_id, :reason

Message Processing Events

  • [:swarm_ex, :agent, :message, :start] - Message processing start

    • Measurement: :system_time
    • Metadata: :agent_id, :message_type, :network_id, :correlation_id, :message_size
  • [:swarm_ex, :agent, :message, :stop] - Message processing completion

    • Measurement: :duration (microseconds), :queue_time (milliseconds)
    • Metadata: :agent_id, :message_type, :network_id, :correlation_id, :result

Tool Execution Events

  • [:swarm_ex, :tool, :execute, :start] - Tool execution start

    • Measurement: :system_time
    • Metadata: :tool_name, :agent_id, :network_id, :correlation_id, :args
  • [:swarm_ex, :tool, :execute, :stop] - Tool execution completion

    • Measurement: :duration (microseconds)
    • Metadata: :tool_name, :agent_id, :network_id, :correlation_id, :result

Health and Resource Events

  • [:swarm_ex, :health, :check] - Periodic health check

    • Measurement: :memory (bytes), :process_count, :message_queue_length
    • Metadata: :node, :network_id
  • [:swarm_ex, :agent, :memory] - Agent memory usage

    • Measurement: :memory (bytes), :heap_size (bytes), :stack_size (bytes)
    • Metadata: :agent_id, :network_id

Summary

Types

Metadata common to all events

Correlation ID for request tracing

Functions

Attaches telemetry event handlers and starts periodic health checks. Call this when your application starts.

Generates a new correlation ID for request tracing.

Emits agent memory usage metrics.

Emits an agent message event with timing and tracing information.

Emits a tool execution event with timing and tracing information.

Types

@type base_metadata() :: %{
  :agent_id => term(),
  :network_id => String.t(),
  :correlation_id => correlation_id(),
  optional(atom()) => term()
}

Metadata common to all events

@type correlation_id() :: String.t()

Correlation ID for request tracing

Functions

Attaches telemetry event handlers and starts periodic health checks. Call this when your application starts.

Options

  • :health_check_interval - Interval in milliseconds between health checks. Defaults to 60_000 (1 minute)
Link to this function

generate_correlation_id()

View Source

Generates a new correlation ID for request tracing.

Link to this function

handle_info(atom, state)

View Source
Link to this function

report_agent_memory(agent_id, network_id)

View Source

Emits agent memory usage metrics.

Link to this function

span_agent_message(agent_id, message_type, network_id, func)

View Source

Emits an agent message event with timing and tracing information.

Link to this function

span_tool_execution(tool_name, agent_id, network_id, args, func)

View Source

Emits a tool execution event with timing and tracing information.