Trait ResourceMonitor

Source
pub trait ResourceMonitor:
    Send
    + Sync
    + Debug
    + 'static {
    // Required methods
    fn monitor_id(&self) -> Cow<'static, str>;
    fn resource_type(&self) -> MonitoredResourceType;
    fn get_usage_report(&self) -> ResourceUsageReport;
    fn as_any(&self) -> &dyn Any;

    // Provided method
    fn update(&self) { ... }
}
Expand description

The core trait for a resource monitor.

A ResourceMonitor is a stateful object, typically living in the khora-infra crate, that knows how to query a specific system resource. The khora-telemetry service will hold a collection of these monitors and periodically call update and get_usage_report on them.

Required Methods§

Source

fn monitor_id(&self) -> Cow<'static, str>

Returns a unique, human-readable identifier for this monitor instance.

Source

fn resource_type(&self) -> MonitoredResourceType

Returns the general type of resource being monitored.

Source

fn get_usage_report(&self) -> ResourceUsageReport

Returns a snapshot of the current usage data for the monitored resource.

Source

fn as_any(&self) -> &dyn Any

Allows downcasting to a concrete ResourceMonitor type.

Provided Methods§

Source

fn update(&self)

Triggers the monitor to update its internal state by polling the resource. This default implementation does nothing, for monitors that update passively.

Implementors§