pub struct IntrospectionStream { /* private fields */ }Expand description
Streaming live-metric dispatcher with per-actor subscriptions.
Backends call emit periodically with fresh LiveMetrics; the
stream fans out to all subscribers registered for the metric’s actor
(plus any “all-actors” subscribers). Subscribers receive metrics via
tokio unbounded MPSC channels, so dispatch is non-blocking.
Broken receivers (dropped by the subscriber) are detected on the next dispatch attempt and auto-pruned.
Implementations§
Source§impl IntrospectionStream
impl IntrospectionStream
Sourcepub fn with_aggregator(aggregator: Arc<MetricAggregator>) -> Self
pub fn with_aggregator(aggregator: Arc<MetricAggregator>) -> Self
Create a stream bound to an existing aggregator.
Sourcepub fn aggregator(&self) -> Arc<MetricAggregator>
pub fn aggregator(&self) -> Arc<MetricAggregator>
Access the underlying aggregator (shared via Arc).
Sourcepub fn subscribe(
&self,
actor_id: ActorId,
interval: Duration,
) -> UnboundedReceiver<LiveMetrics>
pub fn subscribe( &self, actor_id: ActorId, interval: Duration, ) -> UnboundedReceiver<LiveMetrics>
Subscribe to metrics for one actor at the given interval.
Returns the receiver half of a tokio unbounded MPSC channel. The
sender lives inside a SubscriberHandle held by the stream; when
the caller drops the returned receiver, the handle becomes closed
and is pruned on the next dispatch.
An interval of Duration::ZERO is equivalent to unsubscribing — in
that case this function returns a receiver whose sender has already
been dropped.
Sourcepub fn subscribe_all(
&self,
interval: Duration,
) -> UnboundedReceiver<LiveMetrics>
pub fn subscribe_all( &self, interval: Duration, ) -> UnboundedReceiver<LiveMetrics>
Subscribe to metrics for every actor.
interval of Duration::ZERO is equivalent to an immediate no-op
(returns a closed receiver).
Sourcepub fn unsubscribe(&self, actor_id: ActorId)
pub fn unsubscribe(&self, actor_id: ActorId)
Drop every subscription for actor_id.
Sourcepub fn unsubscribe_all(&self)
pub fn unsubscribe_all(&self)
Drop every global “all-actors” subscription.
Sourcepub fn emit(&self, metrics: LiveMetrics)
pub fn emit(&self, metrics: LiveMetrics)
Emit a metric to all applicable subscribers.
Called by backends (CPU dispatcher) or K2H processor (CUDA). Any subscribers whose receiver has been dropped are auto-removed during dispatch. Interval gating is applied per-subscriber, so a fast producer with slow subscribers will not spam them.
Sourcepub fn subscriber_count(&self, actor_id: &ActorId) -> usize
pub fn subscriber_count(&self, actor_id: &ActorId) -> usize
Number of active subscribers for one actor.
Sourcepub fn global_subscriber_count(&self) -> usize
pub fn global_subscriber_count(&self) -> usize
Number of active “all-actors” subscribers.
Sourcepub fn total_subscribers(&self) -> usize
pub fn total_subscribers(&self) -> usize
Total number of active subscribers across all buckets.