Module mz_ore::metrics

source ·
Available on crate feature metrics only.
Expand description

Metrics for materialize systems.

The idea here is that each subsystem keeps its metrics in a scoped-to-it struct, which gets registered (once) to the server’s (or a test’s) prometheus registry.

Instead of using prometheus’s (very verbose) metrics definitions, we rely on type inference to reduce the verbosity a little bit. A typical subsystem will look like the following:

#[derive(Debug, Clone)] // Note that prometheus metrics can safely be cloned
struct Metrics {
    pub bytes_sent: IntCounter,
}

impl Metrics {
    pub fn register_into(registry: &MetricsRegistry) -> Metrics {
        Metrics {
            bytes_sent: registry.register(metric!(
                name: "mz_pg_sent_bytes",
                help: "total number of bytes sent here",
            )),
        }
    }
}

Modules§

  • Support for metrics that get removed from their corresponding metrics vector when dropped.
  • Access to non-delete-on-drop vector types

Structs§

Traits§

  • A trait makes recording a duration generic over different prometheus metrics. This allows us to de-dupe the implemenation of Future for our wrapper Futures like WallTimeFuture and ExecTimeFuture over different kinds of prometheus metrics.
  • A wrapper for creating prometheus metrics more conveniently.
  • Extension trait for metrics vectors.
  • A trait that allows being generic over MetricVecs.
  • Exposes combinators that report metrics related to the execution of a Future to prometheus.
  • An extension trait for types that are valid (or convertible into) prometheus labels: slices/vectors of strings, and BTreeMaps.

Type Aliases§