pub struct SourceMetrics { /* private fields */ }Expand description
Source-stage handles (spate_source_*).
Implementations§
Source§impl SourceMetrics
impl SourceMetrics
Sourcepub fn new(labels: &ComponentLabels) -> Self
pub fn new(labels: &ComponentLabels) -> Self
Resolve all source handles, claiming the spate_source_* series for
these labels.
A pipeline builds several of these on identical labels — one per
pipeline thread plus the controller’s — because every thread counts
records it polled. Only one of them may publish the source gauges,
and it must be the controller’s: it holds the assignment and hands its
clone to the source, which is the only thing that can measure lag. The
per-thread instances are therefore built with shadow,
not this constructor. A collision here logs and shadows rather than
panicking (see “Series ownership” in docs/METRICS.md).
Consumer lag is deliberately not gated by per_partition_detail: the
per-partition series is the only representation of a golden signal,
so a cardinality knob must not be able to delete it. The lag handles
are also not resolved here — PartitionGauges registers a partition’s
series on its first known value, so a partition whose lag has never
been measured is absent rather than reporting a 0 that reads as
“caught up”.
Sourcepub fn try_new(labels: &ComponentLabels) -> Result<Self, MetricsError>
pub fn try_new(labels: &ComponentLabels) -> Result<Self, MetricsError>
Resolve all source handles, failing when another live handle set already owns the series. The pipeline runtime’s path for the controller’s instance — the one that owns lag and lanes.
§Errors
MetricsError::DuplicateSeries on a collision.
Sourcepub fn shadow(labels: &ComponentLabels) -> Self
pub fn shadow(labels: &ComponentLabels) -> Self
Resolve source handles that deliberately do not own their series: counters and the poll histogram record as normal (they aggregate across instances), gauge writes are dropped.
This is how a pipeline thread gets to count its own polls without
competing for spate_source_lag_records and spate_source_lanes_active,
which only the controller can populate correctly. Use it when a second
instance on the same labels is intended; anything else should use
new or try_new and hear about the
collision.
Sourcepub fn poll_duration(&self, d: Duration)
pub fn poll_duration(&self, d: Duration)
Observe one poll call’s duration.
Sourcepub fn set_partition_lag(&self, partition: PartitionId, lag: u64)
pub fn set_partition_lag(&self, partition: PartitionId, lag: u64)
Publish one partition’s consumer lag.
Only call this with a lag the client actually measured. The series is
registered on the first such call, so never publishing is how “lag
unknown” is expressed — a 0 would be indistinguishable from a
consumer that has caught up.
Sourcepub fn retain_partitions(&self, keep: &[PartitionId])
pub fn retain_partitions(&self, keep: &[PartitionId])
Zero and drop the lag series for partitions this member no longer owns.
Load-bearing, but not by deleting anything: the exporter has no
deletion, so a partition that moved to another member would keep
rendering this member’s last lag forever and every reader that sums
across partitions would count it twice. Zeroing first makes the sum
correct — the member that now owns the partition publishes the real
figure, and this one contributes the 0 it truthfully has.
Call this once the new assignment is known, not while partitions are still draining: a member that is about to be handed a partition back should never publish a zero for it.
Sourcepub fn rebalance_assigned(&self)
pub fn rebalance_assigned(&self)
Count a rebalance assignment event.
Sourcepub fn rebalance_revoked(&self)
pub fn rebalance_revoked(&self)
Count a rebalance revocation event.
Sourcepub fn set_lanes_active(&self, lanes: usize)
pub fn set_lanes_active(&self, lanes: usize)
Set the number of currently assigned lanes.