enhancement(host_metrics source): replace heim with sysinfo in network collector - #24818
enhancement(host_metrics source): replace heim with sysinfo in network collector#24818mushrowan wants to merge 1 commit into
Conversation
fd5bc2a to
46660f8
Compare
…ollector replace heim::net::io_counters() with sysinfo::Networks for network metrics collection, as part of removing the unmaintained heim dependency (vectordotdev#23646) - sysinfo already a dep (used by process.rs), no new dependencies - network_transmit_packets_total now emitted on all platforms (was linux/windows only behind heim IoCountersExt) - tx drop counters read from sysfs on linux since sysinfo doesn't expose them yet (same /sys/class/net dir sysinfo reads from) - windows tx drops temporarily unavailable, pending upstream sysinfo - replaces async stream/filter_map chain with simple sync iteration
46660f8 to
3a386c6
Compare
| #[cfg(target_os = "linux")] | ||
| fn read_sysfs_tx_dropped(interface: &str) -> Option<u64> { | ||
| std::fs::read_to_string(format!( | ||
| "/sys/class/net/{interface}/statistics/tx_dropped" | ||
| )) | ||
| .ok() | ||
| .and_then(|s| s.trim().parse().ok()) | ||
| } |
There was a problem hiding this comment.
heim reads this directly from /proc/net/dev in Linux. We also don't want to drop windows support for network_transmit_packets_drop_total. I'd be more confident in merging this in if this were part of upstream sysinfo. Is there an upstream tracking issue for this?
Exploring an idea: is it possible to use heim to get just this one metric? We can could remove it later of course.
| The `host_metrics` source network collector now uses `sysinfo` instead of the | ||
| unmaintained `heim` crate. `network_transmit_packets_total` is now emitted on | ||
| all platforms (previously linux/windows only). Windows `network_transmit_packets_drop_total` | ||
| is temporarily unavailable pending upstream sysinfo support. | ||
|
|
||
| authors: mushrowan |
There was a problem hiding this comment.
| The `host_metrics` source network collector now uses `sysinfo` instead of the | |
| unmaintained `heim` crate. `network_transmit_packets_total` is now emitted on | |
| all platforms (previously linux/windows only). Windows `network_transmit_packets_drop_total` | |
| is temporarily unavailable pending upstream sysinfo support. | |
| authors: mushrowan | |
| The `host_metrics` source now emits `network_transmit_packets_total` on all platforms | |
| (previously Linux and Windows only). Windows `network_transmit_packets_drop_total` | |
| is temporarily unavailable pending upstream sysinfo support. | |
| authors: mushrowan |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a386c664e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tags, | ||
| ); | ||
| } | ||
| let networks = Networks::new_with_refreshed_list(); |
There was a problem hiding this comment.
Honor configured roots when collecting network counters
When host_metrics runs with PROCFS_ROOT/SYSFS_ROOT set—including the checked Kubernetes agent DaemonSet in distribution/kubernetes/vector-agent/daemonset.yaml, which mounts the host at /host/proc and /host/sys—Networks::new_with_refreshed_list() uses sysinfo's hard-coded /sys/class/net Linux backend instead. The old heim collector honored the configured PROCFS_ROOT, so this change reports the container/pod network namespace rather than the host; read_sysfs_tx_dropped also hard-codes /sys. Please preserve root-aware collection for both the main counters and dropped-packet counter.
Useful? React with 👍 / 👎.
| tags, | ||
| ); | ||
| } | ||
| let networks = Networks::new_with_refreshed_list(); |
There was a problem hiding this comment.
Preserve scrape-error telemetry for network read failures
If the OS network query fails—for example because /sys/class/net is unavailable on Linux or GetIfTable2 fails on Windows—sysinfo silently returns an empty collection, so this function emits neither metrics nor an error. The removed heim branch emitted HostMetricsScrapeDetailError, which logged the failure and incremented component_errors_total; without equivalent handling, operators cannot distinguish a broken collector from a host with no interfaces. Use a fallible collection path or otherwise detect and emit the existing internal error event.
AGENTS.md reference: AGENTS.md:L351-L353
Useful? React with 👍 / 👎.
| #[cfg(windows)] | ||
| use heim::net::os::windows::IoCountersExt; | ||
| use heim::units::information::byte; | ||
| use sysinfo::Networks; |
There was a problem hiding this comment.
Stop enabling the unused heim network feature
A repo-wide search shows that this replacement removes the last heim::net use, but sources-host_metrics in Cargo.toml still activates heim/net. Consequently every host-metrics build continues compiling and shipping the unmaintained heim-net subcrate even though the collector now uses sysinfo, defeating this part of the dependency migration and retaining unnecessary build and third-party inventory. Remove heim/net from the feature and refresh the generated dependency artifacts.
Useful? React with 👍 / 👎.
Summary
replace
heim::net::io_counters()withsysinfo::Networksin the host_metricsnetwork collector. first step in removing the unmaintained heim dependency
(#23646). sysinfo is already a dep (used by
process.rs)network_transmit_packets_totalnow emitted on all platforms (was linux/windowsonly). windows tx drops temporarily unavailable since sysinfo doesn't expose
drop counters yet, linux drops preserved via inline sysfs read
Vector configuration
How did you test this PR?
cargo test -p vector --no-default-features --features sources-host_metrics sources::host_metrics::networkChange Type
Is this a breaking change?
Does this PR include user facing changes?
guidelines.
no-changeloglabel to this PR.References
Notes