pub struct Meter { /* private fields */ }Expand description
An instrumentation scope: one component’s three standard labels plus an
spate_<namespace>_ name prefix applied to every metric it mints.
Cheap to clone; the handles it mints are the metrics facade’s own
Arc-backed handles, safe to clone across pipeline threads — every clone
feeds the same series.
use spate_core::metrics::Meter;
// Build-time: resolve the handle once. Pass the LOCAL name — the Meter
// prepends `spate_custom_`, so this registers `spate_custom_orders_enriched_total`.
let meter = Meter::new("orders", "enrich", "map");
let enriched = meter.counter("orders_enriched_total", &[("region", "eu".into())]);
// Hot path: touch only the handle, count per batch.
enriched.increment(512);Implementations§
Source§impl Meter
impl Meter
Sourcepub fn new(
pipeline: impl Into<SharedString>,
component: impl Into<SharedString>,
component_type: impl Into<SharedString>,
) -> Self
pub fn new( pipeline: impl Into<SharedString>, component: impl Into<SharedString>, component_type: impl Into<SharedString>, ) -> Self
A scope for pipeline-author custom metrics: names land under the
spate_custom_ bucket. component is the instance id (e.g. enrich);
component_type the implementation label. Reuse the pipeline /
component values the framework was given so your series join against
its.
Sourcepub fn with_namespace(
namespace: &str,
pipeline: impl Into<SharedString>,
component: impl Into<SharedString>,
component_type: impl Into<SharedString>,
) -> Self
pub fn with_namespace( namespace: &str, pipeline: impl Into<SharedString>, component: impl Into<SharedString>, component_type: impl Into<SharedString>, ) -> Self
A scope under a specific spate_<namespace>_ bucket — for a connector
that owns a segment (e.g. "kafka" → spate_kafka_*).
§Panics
Panics if namespace is empty, is not a lowercase [a-z][a-z0-9_]*
segment, or is one of the framework’s reserved stage roots (source,
sink, …). This is a construction-time wiring check.
Sourcepub fn counter(
&self,
name: &str,
extra: &[(&'static str, SharedString)],
) -> Counter
pub fn counter( &self, name: &str, extra: &[(&'static str, SharedString)], ) -> Counter
Resolve a counter under this scope. name is the local name
(auto-prefixed spate_<namespace>_); it carries the three standard
labels, then extra. Pass &[] for the standard labels alone.
Build-time only.
Follow the taxonomy rules: _total suffix on counters, and push
per-instance identity (a topic, a shard) into extra labels rather
than the name, keeping the name low-cardinality.
Sourcepub fn gauge(&self, name: &str, extra: &[(&'static str, SharedString)]) -> Gauge
pub fn gauge(&self, name: &str, extra: &[(&'static str, SharedString)]) -> Gauge
Resolve a gauge under this scope (local name, auto-prefixed). Build-time only.
Sourcepub fn histogram(
&self,
name: &str,
extra: &[(&'static str, SharedString)],
) -> Histogram
pub fn histogram( &self, name: &str, extra: &[(&'static str, SharedString)], ) -> Histogram
Resolve a histogram under this scope (local name, auto-prefixed).
Build-time only. Give it a unit suffix (_seconds / _bytes /
_rows).
Sourcepub fn labels(&self) -> &ComponentLabels
pub fn labels(&self) -> &ComponentLabels
The underlying standard-label set, for building a framework stage
handle from the same scope (e.g.
DeserMetrics::new).