-
Notifications
You must be signed in to change notification settings - Fork 11
primitives metrics
Magnus Hedemark edited this page Jun 10, 2026
·
1 revision
Active contributors: groktopus
The metrics system provides in-memory counter, histogram, and gauge primitives with OpenMetrics text export for Prometheus consumption. It has zero external dependencies -- the collector is built from Python stdlib types.
The MetricsCollector singleton (METRICS) is a registry that manages thread-safe metric instances:
-
_SafeCounter-- increment-only counter with optional label dimensions -
_SafeHistogram-- bucketed histogram with configurable buckets (default 16 buckets from 5ms to 60s) -
_SafeGauge-- set/inc/dec gauge
All primitives use threading.Lock for thread safety.
Both agent-svc and semantic-svc expose /metrics endpoints:
-
GET /metricson agent-svc (port 8080) -- job counters, scrape latency, queue depth, dependency health -
GET /metricson semantic-svc (port 8003) -- document count, eviction count, request latency per endpoint, embedding duration
| Metric | Type | Labels |
|---|---|---|
groktocrawl_info |
info | version |
http_request_duration_seconds |
histogram | method, path |
scrape_duration_seconds |
histogram | tier |
scrapes_total |
counter | tier |
jobs_submitted_total |
counter | type |
jobs_completed_total |
counter | type |
jobs_failed_total |
counter | type |
job_duration_seconds |
histogram | type, status |
queue_depth |
gauge | -- |
dependency_health |
gauge | dependency |
| File | Purpose |
|---|---|
agent-svc/agent/metrics.py |
MetricsCollector for agent-svc |
semantic-svc/metrics.py |
MetricsCollector for semantic-svc (duplicated) |