Expand description
Statistics services.
It includes:
- A
factoryfunction to build the structs needed to collect the tracker metrics. - A
get_metricsservice to get thetracker metrics.
Tracker metrics are collected using a Publisher-Subscribe pattern.
The factory function builds two structs:
- An statistics
EventSender - An statistics
Repo
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§
- Tracker
Metrics - All the metrics collected by the tracker.
Functions§
- get_
metrics - It returns all the
TrackerMetrics