enhancement(host_metrics source): replace heim with sysinfo for load/host metrics#24819
enhancement(host_metrics source): replace heim with sysinfo for load/host metrics#24819mushrowan wants to merge 1 commit intovectordotdev:masterfrom
Conversation
…t metrics replace heim::cpu::os::unix::loadavg, heim::host::uptime, and heim::host::boot_time with sysinfo::System static methods. removes heim unit imports (ratio, second) from mod.rs
|
spellcheck issue is handled in #24818 |
There was a problem hiding this comment.
Thanks for this! Unfortunately I think this is going to be blocked until the issue I raised over at sysinfo gets addressed, but other than that the code looks good to be merged. I'll circle back to this PR once more commits are pushed (after the issue is addressed in a release)
| Replace heim with sysinfo for load average, uptime, and boot time metrics in the `host_metrics` source | ||
|
|
||
| authors: mushrowan |
There was a problem hiding this comment.
Are heim and sysinfo equivalent in this scenario? If so we don't need a changelog here since this won't have user impact.
| match heim::cpu::os::unix::loadavg().await { | ||
| Ok(loadavg) => { | ||
| output.gauge( | ||
| "load1", | ||
| loadavg.0.get::<ratio>() as f64, | ||
| MetricTags::default(), | ||
| ); | ||
| output.gauge( | ||
| "load5", | ||
| loadavg.1.get::<ratio>() as f64, | ||
| MetricTags::default(), | ||
| ); | ||
| output.gauge( | ||
| "load15", | ||
| loadavg.2.get::<ratio>() as f64, | ||
| MetricTags::default(), | ||
| ); | ||
| } | ||
| Err(error) => { | ||
| emit!(HostMetricsScrapeDetailError { | ||
| message: "Failed to load average info", | ||
| error, | ||
| }); | ||
| } |
There was a problem hiding this comment.
As it stands, System::load_average() reports as infallible but it actually is. Despite heim being unmaintained we currently get better metrics from it do to the fallibility return values from system functions. We want to maintain HostMetricsScrapeDetailError wherever possible. I raised this over at GuillaumeGomez/sysinfo#1656
Summary
replace heim with sysinfo for load average, uptime, and boot time in the
host_metrics source. part of removing the unmaintained heim dependency (#23646)
heim::cpu::os::unix::loadavg()->System::load_average()heim::host::uptime()->System::uptime()heim::host::boot_time()->System::boot_time()all three sysinfo methods are static, sync, and infallible so the error handling
arms are removed
Vector configuration
How did you test this PR?
cargo test -p vector --no-default-features --features sources-host_metrics \ -- sources::host_metrics::tests::generates_loadavg_metrics \ sources::host_metrics::tests::generates_host_metricsChange Type
Is this a breaking change?
Does this PR include user facing changes?
guidelines.
no-changeloglabel to this PR.References
Notes