Skip to main content

SourceMetrics

Struct SourceMetrics 

Source
pub struct SourceMetrics { /* private fields */ }
Expand description

Source-stage handles (spate_source_*).

Implementations§

Source§

impl SourceMetrics

Source

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”.

Source

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.

Source

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.

Source

pub fn batch(&self, records: u64, bytes: u64)

Record one polled batch.

Source

pub fn poll_duration(&self, d: Duration)

Observe one poll call’s duration.

Source

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.

Source

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.

Source

pub fn rebalance_assigned(&self)

Count a rebalance assignment event.

Source

pub fn rebalance_revoked(&self)

Count a rebalance revocation event.

Source

pub fn set_lanes_active(&self, lanes: usize)

Set the number of currently assigned lanes.

Trait Implementations§

Source§

impl Debug for SourceMetrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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