Skip to main content

NodeMetrics

Struct NodeMetrics 

Source
pub struct NodeMetrics {
Show 14 fields pub active_connections: Gauge, pub total_connections: Counter, pub failed_connections: Counter, pub messages_sent: Counter, pub messages_received: Counter, pub messages_dropped: Counter, pub message_size_bytes: Histogram, pub message_latency_ms: Histogram, pub state_sync_latency_ms: Histogram, pub memory_usage_bytes: Gauge, pub cpu_usage_percent: Gauge, pub time_drift_ms: Gauge, pub state_divergence_count: Gauge, pub quarantine_buffer_size: Gauge,
}
Expand description

Core metrics for monitoring ELARA node health and performance.

This struct provides a centralized collection of all key metrics that should be monitored in a production ELARA deployment. Metrics are organized into categories:

  • Connection metrics: Track connection lifecycle and health
  • Message metrics: Track message throughput and reliability
  • Latency metrics: Track performance characteristics
  • Resource metrics: Track system resource usage
  • Protocol metrics: Track protocol-specific health indicators

§Example

use elara_runtime::observability::metrics::{MetricsRegistry, NodeMetrics};

let registry = MetricsRegistry::new();
let metrics = NodeMetrics::new(&registry);

// Track connections
metrics.active_connections.inc();
metrics.total_connections.inc();

// Track messages
metrics.messages_sent.inc();
metrics.message_latency_ms.observe(42.5);

// Track resources
metrics.memory_usage_bytes.set(1024 * 1024 * 512); // 512 MB
metrics.cpu_usage_percent.set(45);

Fields§

§active_connections: Gauge

Number of currently active connections.

§total_connections: Counter

Total number of connections established since node start.

§failed_connections: Counter

Total number of failed connection attempts.

§messages_sent: Counter

Total number of messages sent.

§messages_received: Counter

Total number of messages received.

§messages_dropped: Counter

Total number of messages dropped (e.g., due to queue overflow).

§message_size_bytes: Histogram

Distribution of message sizes in bytes.

§message_latency_ms: Histogram

Distribution of message processing latency in milliseconds.

§state_sync_latency_ms: Histogram

Distribution of state synchronization latency in milliseconds.

§memory_usage_bytes: Gauge

Current memory usage in bytes.

§cpu_usage_percent: Gauge

Current CPU usage as a percentage (0-100).

§time_drift_ms: Gauge

Current time drift from reference time in milliseconds. Positive values indicate local clock is ahead, negative values indicate behind.

§state_divergence_count: Gauge

Number of state divergences detected. This tracks instances where state reconciliation found inconsistencies.

§quarantine_buffer_size: Gauge

Number of events in the quarantine buffer. Events are quarantined when they have missing dependencies.

Implementations§

Source§

impl NodeMetrics

Source

pub fn new(registry: &MetricsRegistry) -> Self

Creates a new NodeMetrics instance and registers all metrics with the provided registry.

This constructor initializes all core metrics with appropriate types and bucket configurations for histograms. All metrics are registered with the provided MetricsRegistry and can be accessed through the returned struct.

§Histogram Buckets
  • message_latency_ms: Buckets optimized for typical message processing times (1ms to 5 seconds)
  • state_sync_latency_ms: Buckets optimized for state synchronization times (10ms to 30 seconds)
  • message_size_bytes: Buckets optimized for typical message sizes (64 bytes to 1 MB)
§Arguments
  • registry - The metrics registry to register all metrics with
§Example
use elara_runtime::observability::metrics::{MetricsRegistry, NodeMetrics};

let registry = MetricsRegistry::new();
let metrics = NodeMetrics::new(&registry);

// Metrics are now registered and ready to use
metrics.active_connections.inc();
Source

pub fn active_connections(&self) -> &Gauge

Returns a reference to the active connections gauge.

Source

pub fn total_connections(&self) -> &Counter

Returns a reference to the total connections counter.

Source

pub fn failed_connections(&self) -> &Counter

Returns a reference to the failed connections counter.

Source

pub fn messages_sent(&self) -> &Counter

Returns a reference to the messages sent counter.

Source

pub fn messages_received(&self) -> &Counter

Returns a reference to the messages received counter.

Source

pub fn messages_dropped(&self) -> &Counter

Returns a reference to the messages dropped counter.

Source

pub fn message_size_bytes(&self) -> &Histogram

Returns a reference to the message size histogram.

Source

pub fn message_latency_ms(&self) -> &Histogram

Returns a reference to the message latency histogram.

Source

pub fn state_sync_latency_ms(&self) -> &Histogram

Returns a reference to the state sync latency histogram.

Source

pub fn memory_usage_bytes(&self) -> &Gauge

Returns a reference to the memory usage gauge.

Source

pub fn cpu_usage_percent(&self) -> &Gauge

Returns a reference to the CPU usage gauge.

Source

pub fn time_drift_ms(&self) -> &Gauge

Returns a reference to the time drift gauge.

Source

pub fn state_divergence_count(&self) -> &Gauge

Returns a reference to the state divergence count gauge.

Source

pub fn quarantine_buffer_size(&self) -> &Gauge

Returns a reference to the quarantine buffer size gauge.

Trait Implementations§

Source§

impl Clone for NodeMetrics

Source§

fn clone(&self) -> NodeMetrics

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeMetrics

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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
Source§

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