Module statistics

Source
Expand description

Statistics services.

It includes:

Tracker metrics are collected using a Publisher-Subscribe pattern.

The factory function builds two structs:

let (stats_event_sender, stats_repository) = factory(tracker_usage_statistics);

The statistics repository is responsible for storing the metrics in memory. The statistics event sender allows sending events related to metrics. There is an event listener that is receiving all the events and processing them with an event handler. Then, the event handler updates the metrics depending on the received event.

For example, if you send the event Event::Udp4Connect:

let result = event_sender.send_event(Event::Udp4Connect).await;

Eventually the counter for UDP connections from IPv4 peers will be increased.

pub struct Metrics {
    // ...
    pub udp4_connections_handled: u64,  // This will be incremented
    // ...
}

Modules§

setup
Setup for the tracker statistics.

Structs§

TrackerMetrics
All the metrics collected by the tracker.

Functions§

get_metrics
It returns all the TrackerMetrics