pub struct Metrics {Show 19 fields
pub http_requests: Family<HttpRequestLabels, Counter>,
pub http_duration: Histogram,
pub retrieve_latency: Histogram,
pub commit_duration: Histogram,
pub ingest_duration: Histogram,
pub ingest_chunks: Counter,
pub remote_fetch_blocks: Counter,
pub remote_push_blocks: Counter,
pub remote_advance_head: Family<AdvanceHeadLabels, Counter>,
pub leiden_mode: Family<LeidenModeLabels, Counter>,
pub leiden_debounce_effective: Gauge,
pub leiden_storm_cap_effective: Gauge,
pub leiden_delta_ratio_effective: Gauge,
pub leiden_mode_current: Gauge,
pub traverse_answer_hard_wall_ms_effective: Gauge,
pub traverse_answer_max_hops_effective: Gauge,
pub traverse_answer_hard_wall_exceeded: Counter,
pub ppr_size_gate_skipped: Family<PprSizeGateLabels, Counter>,
pub ppr_size_gate_threshold: Gauge,
/* private fields */
}Expand description
Server-wide Prometheus metric registry.
Cloned into AppState behind an Arc so every handler gets a
cheap reference. All metrics are registered up-front at construction
time; there is no per-request registry mutation.
Fields§
§http_requests: Family<HttpRequestLabels, Counter>Per-request counter keyed on (method, route, status).
http_duration: HistogramRequest-duration histogram (seconds). Buckets cover 1ms to 10s, which matches the typical range for local-first HTTP calls.
retrieve_latency: HistogramRetrieve-handler latency histogram (seconds). Separate from
http_duration so operators can track hybrid-retrieval cost
without the embed / ingest traffic skewing the distribution.
commit_duration: HistogramCommit-duration histogram (seconds). Covers the end-to-end write path including vector cache invalidation and redb fsync.
ingest_duration: HistogramIngest-pipeline duration histogram (seconds). Measured around
the full POST /v1/ingest run: parse + chunk + extract +
commit. Separate from http_duration + commit_duration so
operators can see where the time went inside a single ingest.
ingest_chunks: CounterTotal chunks produced across every successful /v1/ingest
call. Monotonic counter; divide by ingest_duration’s sample
count for an average-chunks-per-ingest view.
remote_fetch_blocks: Counter/remote/v1/fetch-blocks invocation counter.
remote_push_blocks: Counter/remote/v1/push-blocks invocation counter (counts successful
imports; auth and body-decode failures short-circuit earlier).
remote_advance_head: Family<AdvanceHeadLabels, Counter>/remote/v1/advance-head invocation counter, bucketed by
result (success | cas_mismatch | auth_fail).
leiden_mode: Family<LeidenModeLabels, Counter>Gap 10 R3: Leiden recompute-mode counter, one increment per
community_for_head serve. Labelled full | full_debounced | fallback_stale.
leiden_debounce_effective: GaugeGap 10 R6 (floor-a runtime): effective debounce window in ms.
leiden_storm_cap_effective: GaugeGap 10 R6 (floor-c, default 60): effective commit-storm cap.
leiden_delta_ratio_effective: GaugeGap 10 R6 (floor-c, default 0.5): effective delta-ratio force- full fraction, encoded as parts-per-ten-thousand.
leiden_mode_current: GaugeGap 10 current-mode indicator. 0=full, 1=full_debounced, 2=fallback_stale.
traverse_answer_hard_wall_ms_effective: GaugeGap 09 traverse_answer effective hard-wall ms (tunable mirror).
traverse_answer_max_hops_effective: GaugeGap 09 traverse_answer effective max-hops (tunable mirror).
traverse_answer_hard_wall_exceeded: CounterGap 09 traverse_answer hard-wall breach counter.
ppr_size_gate_skipped: Family<PprSizeGateLabels, Counter>Gap 02 #17: PPR size-gate skipped count, labeled by reason.
Closed vocabulary above_threshold | opted_out.
ppr_size_gate_threshold: GaugeGap 02 #17: effective threshold (mirrors
mnem_core::ppr::PPR_DEFAULT_MAX_NODES tunable).
Implementations§
Source§impl Metrics
impl Metrics
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a fresh registry with all four metric families registered.
Exponential buckets are used so the histograms cover several orders of magnitude with a constant bucket count. The first bucket (1ms for requests, 100us for retrieves/commits) matches the fastest plausible path; the last caps at 10s which is the operator-visible ceiling before a caller typically gives up.
Sourcepub fn encode(&self) -> Result<String, Error>
pub fn encode(&self) -> Result<String, Error>
Encode the current metrics as Prometheus text-exposition format.
§Errors
Returns an std::fmt::Error only if the in-memory writer
rejects a write, which cannot happen for String under normal
conditions. Surfaces the error so callers can turn it into a
500 rather than panic.