Skip to content

enhancement(host_metrics source): replace heim with sysinfo for load/host metrics#24819

Open
mushrowan wants to merge 1 commit intovectordotdev:masterfrom
mushrowan:feat/host-metrics-loadhost-sysinfo
Open

enhancement(host_metrics source): replace heim with sysinfo for load/host metrics#24819
mushrowan wants to merge 1 commit intovectordotdev:masterfrom
mushrowan:feat/host-metrics-loadhost-sysinfo

Conversation

@mushrowan
Copy link
Copy Markdown
Contributor

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

[sources.host_metrics]
type = "host_metrics"
collectors = ["load", "host"]

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_metrics

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our
    guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

…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
@mushrowan mushrowan requested a review from a team as a code owner March 1, 2026 12:18
@github-actions github-actions Bot added domain: sources Anything related to the Vector's sources domain: ci Anything related to Vector's CI environment labels Mar 1, 2026
@mushrowan
Copy link
Copy Markdown
Contributor Author

spellcheck issue is handled in #24818

@mushrowan mushrowan changed the title refactor(host_metrics source): replace heim with sysinfo for load/hos… enhancement(host_metrics source): replace heim with sysinfo for load/host metrics Mar 1, 2026
Copy link
Copy Markdown
Contributor

@thomasqueirozb thomasqueirozb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +1 to +3
Replace heim with sysinfo for load average, uptime, and boot time metrics in the `host_metrics` source

authors: mushrowan
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are heim and sysinfo equivalent in this scenario? If so we don't need a changelog here since this won't have user impact.

Comment on lines -435 to -458
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,
});
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@thomasqueirozb thomasqueirozb added source: host_metrics Anything `host_metrics` source related source: internal_metrics Anything `internal_metrics` source related meta: blocked Anything that is blocked to the point where it cannot be worked on. meta: awaiting author Pull requests that are awaiting their author. and removed source: internal_metrics Anything `internal_metrics` source related labels May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: ci Anything related to Vector's CI environment domain: sources Anything related to the Vector's sources meta: awaiting author Pull requests that are awaiting their author. meta: blocked Anything that is blocked to the point where it cannot be worked on. source: host_metrics Anything `host_metrics` source related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants