Skip to content

Commit

Permalink
fix metrics reset on reconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Jan 12, 2024
1 parent b5551da commit e93412f
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions core/src/runtime/services/metrics_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ impl MetricsService {
});
}

self.application_events
.sender
.try_send(crate::events::Events::MempoolSize {
mempool_size: snapshot.get(&Metric::NetworkMempoolSize) as usize,
})
.unwrap();

self.application_events
.sender
.try_send(crate::events::Events::Metrics { snapshot })
.unwrap();
if snapshot.node_cpu_cores > 0.0 {
self.application_events
.sender
.try_send(crate::events::Events::MempoolSize {
mempool_size: snapshot.get(&Metric::NetworkMempoolSize) as usize,
})
.unwrap();

self.application_events
.sender
.try_send(crate::events::Events::Metrics { snapshot })
.unwrap();
}

self.samples_since_connection.fetch_add(1, Ordering::SeqCst);

Expand All @@ -104,11 +106,8 @@ impl Service for MetricsService {
let this = self.clone();
self.metrics
.register_sink(Arc::new(Box::new(move |snapshot: MetricsSnapshot| {
// TODO - remove this once adjusted in rusty kaspa
if snapshot.node_cpu_cores > 0.0 {
if let Err(err) = this.ingest_metrics_snapshot(Box::new(snapshot)) {
println!("Error ingesting metrics snapshot: {}", err);
}
if let Err(err) = this.ingest_metrics_snapshot(Box::new(snapshot)) {
println!("Error ingesting metrics snapshot: {}", err);
}
None
})));
Expand Down

0 comments on commit e93412f

Please sign in to comment.