Skip to main content
iroh provides support for collecting metrics about your application’s performance and behavior using the iroh-metrics crate. This crate offers a simple and flexible way to define, collect, and report various metrics.

Example

use iroh_metrics::{Counter, MetricsGroup};

/// Define your metrics:
#[derive(Debug, Default, MetricsGroup)]
#[metrics(name = "ping")]
pub struct Metrics {
    /// count of valid ping messages sent
    pub pings_sent: Counter,
    /// count of valid ping messages received
    pub pings_recv: Counter,
}

// elsewhere...
let metrics = Metrics::default();

// increment count of pings we've received
metrics.pings_recv.inc();

Exporting metrics

  • Prometheus: The iroh-metrics crate supports exporting metrics to Prometheus.
  • iroh services: Contact us if you are interested in custom metrics hosting without prometheus.