You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Comprehensive reference for Spacebot's Prometheus metrics. For quick-start setup, see docs/metrics.md. For the published docs, see the metrics page on docs.spacebot.sh.
Feature Gate
All telemetry code is behind the metrics cargo feature flag. Without it, every #[cfg(feature = "metrics")] block compiles out to nothing — zero runtime cost.
cargo build --release --features metrics
The [metrics] config block is always parsed (so config validation works) but has no effect without the feature.
Docker
The Docker image always includes metrics — --features metrics is hardcoded in the Dockerfile. Local development without metrics is still possible via cargo build --release (without the feature flag).
Metric Inventory
All metrics are prefixed with spacebot_. The registry uses a private prometheus::Registry (not the default global one) to avoid conflicts with other libraries.
LLM
spacebot_llm_requests_total
Field
Value
Type
IntCounterVec
Labels
agent_id, model, tier, worker_type
Instrumented in
src/llm/model.rs — SpacebotModel::completion()
Description
Total LLM completion requests (one per completion() call, including retries and fallbacks).
spacebot_llm_request_duration_seconds
Field
Value
Type
HistogramVec
Labels
agent_id, model, tier, worker_type
Buckets
0.1, 0.25, 0.5, 1, 2.5, 5, 10, 15, 30, 60, 120
Instrumented in
src/llm/model.rs — SpacebotModel::completion()
Description
End-to-end LLM request duration in seconds. Includes retry loops and fallback chain traversal.
spacebot_llm_tokens_total
Field
Value
Type
IntCounterVec
Labels
agent_id, model, tier, direction, worker_type
Instrumented in
src/llm/model.rs — SpacebotModel::completion()
Description
Total LLM tokens consumed. direction is one of input, output, or cached_input.
spacebot_llm_estimated_cost_dollars
Field
Value
Type
CounterVec (f64)
Labels
agent_id, model, tier, worker_type
Instrumented in
src/llm/model.rs — SpacebotModel::completion()
Description
Estimated LLM cost in USD. Uses a built-in pricing table (src/llm/pricing.rs).
Note: Costs are best-effort estimates. The pricing table covers major models (Claude 4/3.5/3, GPT-4o, o-series, Gemini, DeepSeek) with a conservative fallback for unknown models ($3/M input, $15/M output).
Implementation note: Duration is tracked via a LazyLock<Mutex<HashMap<String, Instant>>> static keyed by Rig's internal call ID. If a tool call starts but the agent terminates before on_tool_result fires (e.g. leak detection), the timer entry remains — bounded by concurrent tool calls, not a practical concern.
MCP
spacebot_mcp_connections
Field
Value
Type
IntGaugeVec
Labels
server_name, state
Instrumented in
src/mcp.rs
Description
Active MCP connections by server and connection state (connecting, connected, disconnected, failed).
spacebot_mcp_tools_registered
Field
Value
Type
IntGaugeVec
Labels
server_name
Instrumented in
src/mcp.rs
Description
Number of tools registered per MCP server.
spacebot_mcp_connection_attempts_total
Field
Value
Type
IntCounterVec
Labels
server_name, result
Instrumented in
src/mcp.rs
Description
MCP connection attempts. result is success or failure.
spacebot_mcp_tool_calls_total
Field
Value
Type
IntCounterVec
Labels
server_name, tool_name
Instrumented in
src/mcp.rs
Description
MCP tool calls by server and tool name.
spacebot_mcp_reconnects_total
Field
Value
Type
IntCounterVec
Labels
server_name
Instrumented in
src/mcp.rs
Description
MCP reconnection attempts.
spacebot_mcp_connection_duration_seconds
Field
Value
Type
HistogramVec
Labels
server_name
Buckets
0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30
Instrumented in
src/mcp.rs
Description
MCP connection establishment duration in seconds.
spacebot_mcp_tool_call_duration_seconds
Field
Value
Type
HistogramVec
Labels
server_name, tool_name
Buckets
0.01, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30
Instrumented in
src/mcp.rs
Description
MCP tool call duration in seconds.
Channel / Messaging
spacebot_messages_received_total
Field
Value
Type
IntCounterVec
Labels
agent_id, channel_type
Instrumented in
src/agent/channel.rs
Description
Total messages received from external channels.
spacebot_messages_sent_total
Field
Value
Type
IntCounterVec
Labels
agent_id, channel_type
Instrumented in
src/agent/channel.rs
Description
Total messages sent (replies) via channels.
spacebot_message_handling_duration_seconds
Field
Value
Type
HistogramVec
Labels
agent_id, channel_type
Buckets
0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 120
Instrumented in
src/agent/channel.rs
Description
End-to-end message handling duration from receipt to reply.
Memory mutation operations. operation is one of save, delete, or forget.
spacebot_memory_entry_count
Field
Value
Type
IntGaugeVec
Labels
agent_id
Instrumented in
src/memory/store.rs — save() (inc) and delete() (dec)
Description
Approximate memory entry count per agent. Tracks net saves minus deletes — starts at 0 on process start, not the actual database count.
Note: This gauge tracks deltas from process start, not the absolute database count. On restart it resets to 0. For the true count, query the database directly.