Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed Aug 10, 2021
1 parent 4dd1aff commit ed040e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
20 changes: 14 additions & 6 deletions node/overseer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ use self::metrics::Metrics;

use polkadot_node_metrics::{
metrics::{prometheus, Metrics as MetricsTrait},
Metronome,
MemoryAllocationTracker,
MemoryAllocationTracker, Metronome,
};
pub use polkadot_overseer_gen as gen;
pub use polkadot_overseer_gen::{
Expand Down Expand Up @@ -695,18 +694,27 @@ where
}
let subsystem_meters = overseer.map_subsystems(ExtractNameAndMeters);

let memory_stats = MemoryAllocationTracker::new().expect("Jemalloc is the default allocator. qed");
let memory_stats =
MemoryAllocationTracker::new().expect("Jemalloc is the default allocator. qed");

let metronome_metrics = metrics.clone();
let metronome =
Metronome::new(std::time::Duration::from_millis(950)).for_each(move |_| {
match memory_stats.snapshot() {
Ok(memory_stats_snapshot) => {
tracing::trace!(target: LOG_TARGET, "memory_stats: {:?}", &memory_stats_snapshot);
tracing::trace!(
target: LOG_TARGET,
"memory_stats: {:?}",
&memory_stats_snapshot
);
metronome_metrics.memory_stats_snapshot(memory_stats_snapshot);
}
},

Err(e) => tracing::debug!(target: LOG_TARGET, "Failed to obtain memory stats: {:?}", e),
Err(e) => tracing::debug!(
target: LOG_TARGET,
"Failed to obtain memory stats: {:?}",
e
),
}

// We combine the amount of messages from subsystems to the overseer
Expand Down
13 changes: 3 additions & 10 deletions node/overseer/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use super::*;
use polkadot_node_metrics::{
memory_stats::MemoryAllocationSnapshot,
metrics::{self, prometheus}
metrics::{self, prometheus},
};

/// Overseer Prometheus metrics.
Expand Down Expand Up @@ -62,15 +62,9 @@ impl Metrics {
}
}

pub(crate) fn memory_stats_snapshot(
&self,
memory_stats: MemoryAllocationSnapshot,
) {
pub(crate) fn memory_stats_snapshot(&self, memory_stats: MemoryAllocationSnapshot) {
if let Some(metrics) = &self.0 {
let MemoryAllocationSnapshot {
resident,
allocated,
} = memory_stats;
let MemoryAllocationSnapshot { resident, allocated } = memory_stats;

metrics.memory_stats_allocated.set(allocated);
metrics.memory_stats_resident.set(resident);
Expand Down Expand Up @@ -217,7 +211,6 @@ impl metrics::Metrics for Metrics {
)?,
registry,
)?,

};
Ok(Metrics(Some(metrics)))
}
Expand Down

0 comments on commit ed040e3

Please sign in to comment.