Skip to main content

Metrics

Struct Metrics 

Source
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: Histogram

Request-duration histogram (seconds). Buckets cover 1ms to 10s, which matches the typical range for local-first HTTP calls.

§retrieve_latency: Histogram

Retrieve-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: Histogram

Commit-duration histogram (seconds). Covers the end-to-end write path including vector cache invalidation and redb fsync.

§ingest_duration: Histogram

Ingest-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: Counter

Total 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: Gauge

Gap 10 R6 (floor-a runtime): effective debounce window in ms.

§leiden_storm_cap_effective: Gauge

Gap 10 R6 (floor-c, default 60): effective commit-storm cap.

§leiden_delta_ratio_effective: Gauge

Gap 10 R6 (floor-c, default 0.5): effective delta-ratio force- full fraction, encoded as parts-per-ten-thousand.

§leiden_mode_current: Gauge

Gap 10 current-mode indicator. 0=full, 1=full_debounced, 2=fallback_stale.

§traverse_answer_hard_wall_ms_effective: Gauge

Gap 09 traverse_answer effective hard-wall ms (tunable mirror).

§traverse_answer_max_hops_effective: Gauge

Gap 09 traverse_answer effective max-hops (tunable mirror).

§traverse_answer_hard_wall_exceeded: Counter

Gap 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: Gauge

Gap 02 #17: effective threshold (mirrors mnem_core::ppr::PPR_DEFAULT_MAX_NODES tunable).

Implementations§

Source§

impl Metrics

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Metrics

Source§

fn clone(&self) -> Metrics

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Metrics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,