Skip to main content

Crate hyprstream_metrics

Crate hyprstream_metrics 

Source
Expand description

Metrics engine: storage, aggregation, and query execution.

This crate is the serving/engine half of the metrics substrate (AGPL-3.0-only): DuckDB and DataFusion backends, the query planner and orchestrator, metric aggregation execution, and checkpointing. The public record types, schema, producer API, and the calibration / decision-batch stores live in the Apache-2.0 hyprstream-metrics-api crate; everything consumers need is re-exported here so existing hyprstream_metrics::... paths keep working.

Re-exports§

pub use checkpoint::Checkpoint;
pub use checkpoint::CheckpointConfig;
pub use checkpoint::CheckpointManager;
pub use checkpoint::CheckpointMetadata;
pub use checkpoint::RecoveryManager;
pub use checkpoint::RecoveryStatus;
pub use checkpoint::RegistryClient;
pub use checkpoint::RegistryError;
pub use query::CachedStatement;
pub use query::DataFusionExecutor;
pub use query::DataFusionPlanner;
pub use query::ExecutorConfig;
pub use query::Query;
pub use query::QueryOrchestrator;
pub use storage::context::context_schema;
pub use storage::context::ContextRecord;
pub use storage::context::ContextStore;
pub use storage::context::SearchResult;
pub use storage::context::DEFAULT_EMBEDDING_DIM;
pub use duckdb::arrow;

Modules§

aggregation
Core aggregation framework for time-series data.
checkpoint
Checkpoint system for versioned metrics storage.
config
Configuration management for hyprstream-metrics library.
error
metrics
Metric record types, stores, and metric-specific aggregation.
query
Query planning and execution module.
storage
Storage backends for SQL database operations.
utils

Structs§

AggregateResult
Result of an aggregation operation
CalibrationParams
One calibration parameter row.
CalibrationStore
Calibration parameter store over any StorageBackend: the writer API for the P2.2 re-fit loop and the reader API for serving.
ConformalQuantile
One coverage level → nonconformity quantile (APS/RAPS-style).
DecisionBatchMeta
Row metadata for one stored decision batch (everything but the payload).
DecisionBatchStore
Decision-batch store over any StorageBackend: the write/read API for Arrow-native model output (eval harness, distillation corpora, re-fit input).
DirichletParams
Dirichlet-calibration parameters (Kull et al. 2019) for high-cardinality choice questions, where scalar temperature underfits: calibrated log-probs are W · ln(p) + b with weights row-major K×K and bias of length K.
GroupBy
Grouping specification for aggregation
MetricsProducer
Producer of schema-v2 metric rows over any StorageBackend.
OrdinalInterval
One coverage level → ordinal contiguous interval half-widths, in level units, applied around the predicted level (min-CPS / RPS-based nonconformity for the score primitive).
VersionTriple
The (schema, model, calib) version triple keying every calibration row.

Enums§

AggregateFunction
Generic aggregation functions that can be applied to time-series data
ConformalParams
Conformal parameters for one primitive. Score questions are ordinal, so their prediction sets are contiguous intervals; noul/choice use APS/RAPS-style quantiles.
DecisionPrimitive
Decision primitive a calibration row applies to (jev-1 profile superset).
TimeWindow
Time window for aggregation

Constants§

CALIBRATION_TABLE
Calibration parameter table name.
DECISION_BATCH_TABLE
Decision batch table name.
METRICS_SCHEMA_VERSION
Version of the metrics table schema emitted by get_metrics_schema. v1: five running-window columns; v2: adds labels and tenant_id.
METRICS_TABLE
Primary metrics table name.

Traits§

StorageBackend
Storage backend trait for SQL database operations.

Functions§

calibration_params_schema
Arrow schema of the calibration_params table. Vector/composite params are stored as JSON in nullable VARCHAR columns (the crate’s existing convention for composite values, queryable via DuckDB JSON functions).
create_schema_v2_tables
Creates all schema-v2 tables and migrates pre-v2 metrics tables in place.
decision_batch_schema
Arrow schema of the decision_batches table.
mint_batch_id
Mint a new batch id.
mint_calib_version
Mint a new calibration version id. Re-fits call this (or supply their own) and insert a new row; existing rows are never mutated.