Skip to content

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 histograms
  • lazy_static -- global static metric instances
  • chrono -- 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

TypeDescription
SEARCH_REQUESTS_TOTALCounter vec for search requests by collection and status
SEARCH_LATENCY_SECONDSHistogram vec for search latency by collection
INSERT_REQUESTS_TOTALCounter vec for insert requests
VECTORS_TOTALGauge vec for total vectors stored per collection
MetricsRecorderHelper for recording operation metrics
HealthCheckerReadiness and liveness probe logic
HealthResponseHealth check result with per-collection status
gather_metrics()Export all metrics in Prometheus text format

Released under the MIT License.