Skip to content

Commit 65d12c4

Browse files
committed
Don't panic if unable to identify host in metrics
1 parent 7af2dd9 commit 65d12c4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

xtask/src/metrics.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct Host {
160160

161161
impl Metrics {
162162
fn new(sh: &Shell) -> anyhow::Result<Metrics> {
163-
let host = Host::new(sh)?;
163+
let host = Host::new(sh).unwrap_or_else(|_| Host::unknown());
164164
let timestamp = SystemTime::now();
165165
let revision = cmd!(sh, "git rev-parse HEAD").read()?;
166166
let perf_revision = "a584462e145a0c04760fd9391daefb4f6bd13a99".into();
@@ -191,9 +191,13 @@ impl Metrics {
191191
}
192192

193193
impl Host {
194+
fn unknown() -> Host {
195+
Host { os: "unknown".into(), cpu: "unknown".into(), mem: "unknown".into() }
196+
}
197+
194198
fn new(sh: &Shell) -> anyhow::Result<Host> {
195199
if cfg!(not(target_os = "linux")) {
196-
return Ok(Host { os: "unknown".into(), cpu: "unknown".into(), mem: "unknown".into() });
200+
return Ok(Host::unknown());
197201
}
198202

199203
let os = read_field(sh, "/etc/os-release", "PRETTY_NAME=")?.trim_matches('"').to_owned();

0 commit comments

Comments
 (0)