Struct IntrospectionStream
pub struct IntrospectionStream {
subscriptions: RwLock<RawRwLock, HashMap<ActorId, Vec<Arc<SubscriberHandle>>>>,
global_subscriptions: RwLock<RawRwLock, Vec<Arc<SubscriberHandle>>>,
aggregator: Arc<MetricAggregator>,
next_subscription_id: AtomicU64,
}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.
Fields§
§subscriptions: RwLock<RawRwLock, HashMap<ActorId, Vec<Arc<SubscriberHandle>>>>§global_subscriptions: RwLock<RawRwLock, Vec<Arc<SubscriberHandle>>>§aggregator: Arc<MetricAggregator>§next_subscription_id: AtomicU64Implementations§
§impl IntrospectionStream
impl IntrospectionStream
pub fn new() -> IntrospectionStream
pub fn new() -> IntrospectionStream
Create a new introspection stream with a fresh aggregator.
pub fn with_aggregator(aggregator: Arc<MetricAggregator>) -> IntrospectionStream
pub fn with_aggregator(aggregator: Arc<MetricAggregator>) -> IntrospectionStream
Create a stream bound to an existing aggregator.
pub fn aggregator(&self) -> Arc<MetricAggregator>
pub fn aggregator(&self) -> Arc<MetricAggregator>
Access the underlying aggregator (shared via Arc).
pub 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.
pub 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).
pub fn unsubscribe(&self, actor_id: ActorId)
pub fn unsubscribe(&self, actor_id: ActorId)
Drop every subscription for actor_id.
pub fn unsubscribe_all(&self)
pub fn unsubscribe_all(&self)
Drop every global “all-actors” subscription.
pub 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.
pub fn subscriber_count(&self, actor_id: &ActorId) -> usize
pub fn subscriber_count(&self, actor_id: &ActorId) -> usize
Number of active subscribers for one actor.
pub fn global_subscriber_count(&self) -> usize
pub fn global_subscriber_count(&self) -> usize
Number of active “all-actors” subscribers.
pub fn total_subscribers(&self) -> usize
pub fn total_subscribers(&self) -> usize
Total number of active subscribers across all buckets.
Trait Implementations§
§impl Debug for IntrospectionStream
impl Debug for IntrospectionStream
§impl Default for IntrospectionStream
impl Default for IntrospectionStream
§fn default() -> IntrospectionStream
fn default() -> IntrospectionStream
Auto Trait Implementations§
impl !Freeze for IntrospectionStream
impl !RefUnwindSafe for IntrospectionStream
impl Send for IntrospectionStream
impl Sync for IntrospectionStream
impl Unpin for IntrospectionStream
impl !UnwindSafe for IntrospectionStream
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more