spt-metrics
Prometheus-compatible metrics collection for SPT vector databases
Overview
spt-metrics provides pre-defined Prometheus counters, gauges, and histograms for monitoring SPT vector database operations. It tracks search/insert/delete request counts and latencies, vector and collection totals, memory usage, and uptime. Metrics are exported in Prometheus text format for scraping by monitoring infrastructure.
Key Features
- Search metrics -- request counts and latency histograms per collection
- Insert/delete metrics -- operation counters with success/failure labels
- System metrics -- memory usage gauge and uptime counter
- Health checking -- readiness and liveness probes with collection health status
- Prometheus text export --
gather_metrics()returns scrape-ready text format
Dependencies
Key internal dependencies:
prometheus-- metrics registry, counters, gauges, and histogramslazy_static-- global static metric instanceschrono-- timestamping for health checks
Usage
rust
use spt_metrics::{SEARCH_REQUESTS_TOTAL, SEARCH_LATENCY_SECONDS, gather_metrics};
// Record a search
SEARCH_REQUESTS_TOTAL.with_label_values(&["my_collection", "success"]).inc();
// Export all metrics
let output = gather_metrics();
println!("{}", output);API Reference
Core Types
| Type | Description |
|---|---|
SEARCH_REQUESTS_TOTAL | Counter vec for search requests by collection and status |
SEARCH_LATENCY_SECONDS | Histogram vec for search latency by collection |
INSERT_REQUESTS_TOTAL | Counter vec for insert requests |
VECTORS_TOTAL | Gauge vec for total vectors stored per collection |
MetricsRecorder | Helper for recording operation metrics |
HealthChecker | Readiness and liveness probe logic |
HealthResponse | Health check result with per-collection status |
gather_metrics() | Export all metrics in Prometheus text format |