Skip to main content

Aggregator

Struct Aggregator 

Source
pub struct Aggregator { /* private fields */ }

Implementations§

Source§

impl Aggregator

Source

pub fn new(prefix: String) -> Aggregator

Source

pub fn set_up_prefix(&mut self, prefix: String)

Source

pub fn set_up_remote(&mut self, socket: UdpSocket, addr: SocketAddr)

Source

pub fn set_up_origin(&mut self, origin: String)

Source

pub fn set_up_tagged_metrics(&mut self, tagged: bool)

Source

pub fn set_up_detail(&mut self, detail: MetricDetailLevel)

Set the static cardinality floor (MetricsConfig.detail from the TOML configuration). Live leases applied via Self::lease_apply can elevate the effective level at runtime; the configured floor is the lower bound the worker falls back to when no lease is active.

See MetricDetailLevel and [filter_labels_for_detail] for the per-level filtering rules.

Source

pub fn detail_configured(&self) -> MetricDetailLevel

Returns the static (configured) cardinality floor. Independent of runtime leases.

Source

pub fn detail_effective(&self) -> MetricDetailLevel

Returns the cardinality level actually applied to emissions. Equal to max(configured, max(active leases)).

Source

pub fn lease_apply( &mut self, client_id: String, level: MetricDetailLevel, ttl: Duration, binding: PeerBinding, ) -> LeaseApplyOutcome

Apply or renew a runtime cardinality lease for client_id. If a lease for the same client already exists it is REPLACED (used for renewals). ttl values above LEASE_TTL_MAX are rejected with LeaseApplyOutcome::TtlOutOfRange (NOT clamped); callers must handle that arm or pre-validate the TTL. On success the call returns (previous_effective, new_effective) so callers can decide whether to emit a MetricDetailChanged audit event.

The proto contract on SetMetricDetail.ttl_seconds is that the worker rejects out-of-range values with a FAILURE response — that enforcement lives at the dispatch site in lib/src/server.rs::notify. lease_apply itself returns LeaseApplyOutcome::TtlOutOfRange when called with ttl > LEASE_TTL_MAX so callers that bypass the dispatch site (proto fuzzing, future internal use) see a loud rejection instead of silently capped semantics. Same shape for over-long client_id and a full lease table — see LeaseApplyOutcome for the failure arms.

Source

pub fn lease_clear( &mut self, client_id: &str, presented: PeerBinding, ) -> LeaseClearOutcome

Explicitly release a lease keyed by client_id. The clear is authorised against the apply-time PeerBinding when one was recorded — see LeaseClearOutcome for the three result states. A clear request with presented = PeerBinding::default() matches only leases whose apply-time binding was also unknown, preserving compat with pre-binding callers and platforms without SO_PEERCRED.

Source

pub fn lease_count(&self) -> u32

Returns the number of active (non-expired-as-of-last-tick) leases. Surfaced in WorkerMetricDetailStatus so the TUI can show “another client is still leasing this level”.

Source

pub fn lease_tick(&mut self, now: Instant) -> Option<MetricDetailLevel>

Polled lease-expiry janitor. Called from the worker’s notify loop (and from periodic timers); cheap when nothing has expired. Returns Some(previous_effective) when at least one lease expired AND that expiry actually moved the effective level (so the caller can emit a MetricDetailChanged audit event), or None for the no-change path.

now is parameterised so unit tests can advance the clock deterministically without sleeping.

Source

pub fn lease_tick_due(&self, now: Instant) -> bool

True when at least [LEASE_TICK_INTERVAL] has passed since the last lease_tick. Use to gate the polled janitor at the top of notify without paying a HashMap walk on every event-loop iteration.

Source

pub fn socket(&self) -> Option<&UdpSocket>

Source

pub fn socket_mut(&mut self) -> Option<&mut UdpSocket>

Source

pub fn count_add(&mut self, key: &'static str, count_value: i64)

Source

pub fn set_gauge(&mut self, key: &'static str, gauge_value: usize)

Source

pub fn gauge_add(&mut self, key: &'static str, gauge_value: i64)

Source

pub fn writable(&mut self)

Source

pub fn send_data(&mut self)

Source

pub fn dump_local_proxy_metrics(&mut self) -> BTreeMap<String, FilteredMetrics>

Source

pub fn query( &mut self, q: &QueryMetricsOptions, ) -> Result<ResponseContent, MetricError>

Source

pub fn clear_local(&mut self)

Source

pub fn configure(&mut self, config: &MetricsConfiguration)

Source

pub fn remove_cluster(&mut self, cluster_id: &str)

Drop all metric storage for a cluster across BOTH drains and arm the per-drain tombstone so subsequent emissions for the cluster are dropped on the floor instead of resurrecting the row via entry().or_default(). Called from the worker IPC dispatch on [RequestType::RemoveCluster]. Network-side draining the queued MetricLines produces immediate silence on the wire (any unsent statsd interval for the cluster is discarded).

Worker-event-loop only — METRICS is a thread_local!, and the mutable borrow taken here must not be re-entered from a session- bound code path. Calling this from a metrics emission site would deadlock the thread-local on borrow_mut.

Source

pub fn add_cluster(&mut self, cluster_id: &str)

Re-arm a previously-removed cluster id across BOTH drains. Called from the worker IPC dispatch on [RequestType::AddCluster]. Idempotent on ids that were never removed. Without this hook a cluster removed then re-added would stay tombstoned forever and every fresh metric emission would be dropped.

Source

pub fn remove_backend(&mut self, cluster_id: &str, backend_id: &str)

Drop all metric storage for one backend across BOTH drains. Called from the worker IPC dispatch on [RequestType::RemoveBackend]. Does NOT tombstone the cluster (only remove_cluster does).

Trait Implementations§

Source§

impl Subscriber for Aggregator

Source§

fn receive_metric( &mut self, label: &'static str, cluster_id: Option<&str>, backend_id: Option<&str>, metric: MetricValue, )

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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