Ragex. MCP. Telemetry
(Ragex v0.17.0)
View Source
Tracks MCP tool invocation patterns and latencies.
Backed by an ETS table for near-zero overhead (~1us per write).
Persists to ~/.ragex/telemetry/<project_hash>.etf on shutdown
and reloads on start.
Recorded Metrics (per tool)
:count-- total invocations:total_time_us-- cumulative execution time in microseconds:last_invoked-- DateTime of last call:error_count-- number of failed invocations
Integration
Wrap any tool call with execute/3:
Telemetry.execute("semantic_search", fn -> Tools.call_tool(name, args) end)Or use the :telemetry library events:
[:ragex, :tool, :start]-- emitted before tool execution[:ragex, :tool, :stop]-- emitted after successful execution[:ragex, :tool, :exception]-- emitted on error
Summary
Functions
Returns a specification to start this module under a supervisor.
Execute a tool function and record telemetry.
Get stats for all tools or a specific tool.
Get stats for a single tool.
Record a failed tool invocation.
Record a successful tool invocation.
Clear all telemetry data.
Return total invocations across all tools.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Execute a tool function and record telemetry.
Returns the result of fun.() unchanged.
Get stats for all tools or a specific tool.
Options
:sort_by--:count|:avg_time|:total_time(default:count):period--:all|:today|:last_hour(default:all)
Get stats for a single tool.
@spec record_error(String.t(), non_neg_integer()) :: :ok
Record a failed tool invocation.
@spec record_success(String.t(), non_neg_integer()) :: :ok
Record a successful tool invocation.
@spec reset() :: :ok
Clear all telemetry data.
@spec total_invocations() :: non_neg_integer()
Return total invocations across all tools.