Skip to content

Commit 8f103b3

Browse files
committed
more recoverable error work
Signed-off-by: Brian L. Troutwine <[email protected]>
1 parent 2868d32 commit 8f103b3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lading/src/observer/linux/cgroup.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{collections::VecDeque, io};
66
use nix::errno::Errno;
77
use procfs::process::Process;
88
use rustc_hash::FxHashSet;
9-
use tracing::error;
9+
use tracing::{debug, error};
1010

1111
#[derive(thiserror::Error, Debug)]
1212
/// Errors produced by functions in this module
@@ -80,13 +80,24 @@ impl Sampler {
8080
// Now iterate the pids and collect the unique names of the cgroups associated.
8181
let mut cgroups = FxHashSet::default();
8282
for pid in pids {
83-
let cgroup_path = v2::get_path(pid).await?;
84-
cgroups.insert(cgroup_path);
83+
match v2::get_path(pid).await {
84+
Ok(cgroup_path) => {
85+
cgroups.insert(cgroup_path);
86+
}
87+
Err(err) => {
88+
debug!("Unable to get cgroup path for pid {pid}: {err}");
89+
}
90+
}
8591
}
8692

8793
// Now iterate the cgroups and collect samples.
8894
for cgroup_path in cgroups {
89-
v2::poll(cgroup_path, &self.labels).await?;
95+
if let Err(err) = v2::poll(&cgroup_path, &self.labels).await {
96+
error!(
97+
"Unable to poll cgroup metrics for {path}: {err}",
98+
path = cgroup_path.to_string_lossy()
99+
);
100+
}
90101
}
91102
Ok(())
92103
}

lading/src/observer/linux/cgroup/v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(crate) async fn get_path(pid: i32) -> Result<PathBuf, Error> {
4343
}
4444

4545
/// Polls for any cgroup metrics that can be read, v2 version.
46-
pub(crate) async fn poll(file_path: PathBuf, labels: &[(String, String)]) -> Result<(), Error> {
46+
pub(crate) async fn poll(file_path: &Path, labels: &[(String, String)]) -> Result<(), Error> {
4747
// Read all files in the cgroup `path` and create metrics for them. If we
4848
// lack permissions to read we skip the file. We do not use ? to allow for
4949
// the maximal number of files to be read.

0 commit comments

Comments
 (0)