Documentation
¶
Overview ¶
HIP-0106 Mount() entry point for the native metrics subsystem.
import _ "github.com/hanzoai/metrics" // init() registers the subsystem
At startup the cloud binary iterates its registry and calls Mount() for each enabled subsystem, attaching /v1/metrics/* to the shared zip.App. Ingest is luxfi/metric.MetricBatch (the ZAP MsgMetricBatch payload); storage and query are native — there is no prometheus, no scrape endpoint, no /api/ path.
Package metrics is the native, ZAP-native, prometheus-free time-series store for the Hanzo cloud. It replaces the vendored Grafana/Prometheus observability backends with a small in-process store that ingests luxfi/metric.MetricBatch (the same wire shape the ZAP MsgMetricBatch transport carries) and serves range queries under /v1/metrics/*.
The storage API is deliberately tiny (Append + Query + SeriesCount) so a durable per-tenant backend (DataDir-backed, columnar) can replace the in-memory map without changing mount.go or ingest.go. There is ZERO prometheus here.
Index ¶
Constants ¶
const Version = "0.1.0"
Version is surfaced on /v1/metrics/health.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Sample ¶
Sample is a single timestamped value. Ts is nanoseconds since the Unix epoch to match luxfi/metric.MetricBatch.TimestampNs.
type Series ¶
type Series struct {
Name string `json:"name"`
Labels map[string]string `json:"labels,omitempty"`
Samples []Sample `json:"samples"`
}
Series is a named, labeled append-only stream of samples.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the native in-memory time-series store. Each series is bounded to maxPerSeries samples (oldest evicted first). Safe for concurrent use.
func NewStore ¶
func NewStore() *Store
NewStore returns an empty store with a default per-series retention of 64Ki samples (a real deployment sets this from config / per-tenant quota).
func (*Store) Append ¶
Append adds one sample to the series identified by (name, labels), creating the series on first write and evicting the oldest sample past retention.
func (*Store) IngestBatch ¶
func (s *Store) IngestBatch(b *metric.MetricBatch) int
IngestBatch writes every sample in a luxfi/metric.MetricBatch into the store. This is the exact wire type the ZAP MsgMetricBatch transport carries, so the same code path serves both the HTTP /v1/metrics/batch endpoint and a future ZAP receiver. Counter/gauge values land directly; histogram/summary families contribute derived <name>_sum and <name>_count series. Returns samples written.
func (*Store) Query ¶
Query returns copies of every series whose Name equals name (or all, if name is "") and whose labels are a superset of matchers, with samples restricted to [startNs, endNs] (a zero bound is treated as unbounded).
func (*Store) SeriesCount ¶
SeriesCount reports the number of distinct series held (surfaced on /health).