Skip to content

Commit

Permalink
reuse entry
Browse files Browse the repository at this point in the history
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
  • Loading branch information
blt committed Dec 14, 2024
1 parent 144ee6d commit 2d6266e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lading/src/observer/linux/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ impl Sampler {
// Now iterate the cgroups and collect samples.
for cgroup_path in cgroups {
// If we haven't seen this cgroup before, initialize its CgroupInfo.
self.cgroup_info
let cinfo = self
.cgroup_info
.entry(cgroup_path.clone())
.or_insert_with(|| CgroupInfo {
cpu_sampler: v2::cpu::Sampler::new(),
Expand All @@ -132,11 +133,6 @@ impl Sampler {
path = cgroup_path.to_string_lossy()
);
}
// SAFETY: We just inserted this entry, so it must exist.
let cinfo = self
.cgroup_info
.get_mut(&cgroup_path)
.expect("catastrophic programming error");

if let Err(err) = cinfo.cpu_sampler.poll(&cgroup_path, &self.labels).await {
error!(
Expand Down

0 comments on commit 2d6266e

Please sign in to comment.