This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/server/metrics/metrics.go
Jeffrey Smith f0dd43144e rebrand: Switchboard Core → Armature
- Rename Go module switchboard-core → armature (155+ files)
- Rename Docker image → gobha/armature
- Rename K8s resources, secrets, deployments
- Rename Prometheus metrics switchboard_* → armature_*
- Rename env vars SWITCHBOARD_ADMIN_* → ARMATURE_ADMIN_*
- Rename DB names switchboard_core* → armature*
- Update all frontend branding, notification templates, docs
- Update CI scripts, e2e tests, Keycloak realm, nginx conf
- Rename scripts/switchboard-ca.sh → scripts/armature-ca.sh
- Rename k8s/switchboard.yaml → k8s/armature.yaml
- Rename chart alerting/dashboard files
- Fix: DockerHub push uses env: binding for secret injection
- Helm chart updated (name, labels, template functions, dashboard, alerting)
- Replace favicon/icon assets with Armature brand

No functional changes. Pure mechanical rename + CI fix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 21:39:58 +00:00

98 lines
3.8 KiB
Go

// Package metrics defines all Prometheus metrics for Armature Core.
// All metrics use the "armature_" prefix. Registered via promauto
// so they are available on the default registry's /metrics endpoint.
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
// ── HTTP Request Metrics ────────────────────
var (
HTTPRequestsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "armature_http_requests_total",
Help: "Total HTTP requests by method, path pattern, and status code.",
}, []string{"method", "path_pattern", "status"})
HTTPRequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
Name: "armature_http_request_duration_seconds",
Help: "HTTP request latency in seconds.",
Buckets: []float64{0.01, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30},
}, []string{"method", "path_pattern"})
)
// ── WebSocket Metrics ───────────────────────
var WebSocketConnections = promauto.NewGauge(prometheus.GaugeOpts{
Name: "armature_websocket_connections",
Help: "Current number of active WebSocket connections.",
})
// ── Completion / Token Metrics ──────────────
var (
CompletionTokensTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "armature_completion_tokens_total",
Help: "Total tokens processed by direction (prompt|completion) and model.",
}, []string{"direction", "model_id"})
CompletionsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "armature_completions_total",
Help: "Total completion requests by provider, model, and status.",
}, []string{"provider_config_id", "model_id", "status"})
CompletionDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
Name: "armature_completion_duration_seconds",
Help: "Completion request latency (wall time including tool loops).",
Buckets: []float64{0.1, 0.5, 1, 2, 5, 10, 30, 60, 120},
}, []string{"provider_config_id", "model_id"})
)
// ── Provider Health ─────────────────────────
var ProviderStatus = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "armature_provider_status",
Help: "Provider health status: 0=unknown, 1=healthy, 2=degraded, 3=down.",
}, []string{"provider_config_id"})
// ── Database Pool Metrics ───────────────────
var (
DBOpenConnections = promauto.NewGauge(prometheus.GaugeOpts{
Name: "armature_db_open_connections",
Help: "Number of open database connections.",
})
DBInUseConnections = promauto.NewGauge(prometheus.GaugeOpts{
Name: "armature_db_in_use_connections",
Help: "Number of database connections currently in use.",
})
DBIdleConnections = promauto.NewGauge(prometheus.GaugeOpts{
Name: "armature_db_idle_connections",
Help: "Number of idle database connections.",
})
DBWaitCount = promauto.NewGauge(prometheus.GaugeOpts{
Name: "armature_db_wait_count_total",
Help: "Total number of connections waited for.",
})
DBWaitDuration = promauto.NewGauge(prometheus.GaugeOpts{
Name: "armature_db_wait_duration_seconds_total",
Help: "Total time blocked waiting for a new connection (seconds).",
})
)
// ── Task Scheduler Metrics ──────────────────
var TaskExecutionsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "armature_task_executions_total",
Help: "Total task executions by status (success|error).",
}, []string{"status"})
// ── Sandbox Metrics ─────────────────────────
var SandboxExecutionsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "armature_sandbox_executions_total",
Help: "Total Starlark sandbox executions by entry point and status.",
}, []string{"entry_point", "status"})