There is a bug in the Torrust Demo with the new metrics that I can't reproduce locally.
I will introduce some changes to the metrics package to help me find the problem.
I will also make other minor changes in that package and other packages.
Subtasks
metrics package:
- Return errors instead of panicking in the
MetricCollection struct.
- Add tracing crate.
- Return an optional in
get_counter_value and get_gauge_value. They are returning the default value for that metric type if the metric does not exist. That the behavior we want for increase_counter and set_gauge but not for these methods. They are currently used only in tests.
http-tracker-code, udp-tracker-core, udp-tracker-server packages:
- Add logs to listeners initialization
Change this:
pub fn run_event_listener(&mut self, receiver: Receiver<Event>) {
let stats_repository = self.repository.clone();
tokio::spawn(async move { dispatch_events(receiver, stats_repository).await });
}
To something like this:
pub fn run_event_listener(&mut self, receiver: Receiver<Event>) {
let stats_repository = self.repository.clone();
// TARGET should be HTTP_TRACKER_CORE
tracing::info!(TARGET, "Starting event listener");
tokio::spawn(async move {
dispatch_events(receiver, stats_repository).await;
tracing::info!(TARGET, "Event listener finished");
});
}
NOTE: This won't help identify a panic inside the dispatch_events function. We should log the error returned by tokio::spawn, but the function is not async. We need to move the function call from the app setup to the app start as described here.
There is a bug in the Torrust Demo with the new metrics that I can't reproduce locally.
I will introduce some changes to the
metricspackage to help me find the problem.I will also make other minor changes in that package and other packages.
Subtasks
metricspackage:MetricCollectionstruct.get_counter_valueandget_gauge_value. They are returning the default value for that metric type if the metric does not exist. That the behavior we want forincrease_counterandset_gaugebut not for these methods. They are currently used only in tests.http-tracker-code,udp-tracker-core,udp-tracker-serverpackages:Change this:
To something like this:
NOTE: This won't help identify a panic inside the
dispatch_eventsfunction. We should log the error returned bytokio::spawn, but the function is not async. We need to move the function call from the app setup to the app start as described here.