From be0dfd0e5c2bc201bbb02604b1805ee4926d94d1 Mon Sep 17 00:00:00 2001
From: Povilas Versockas
Date: Fri, 25 Oct 2024 09:05:46 +0300
Subject: [PATCH] [receiver/hostmetrics] fix filesystem scraper root_path
support
---
.chloggen/hostmetrics.yaml | 27 +++++++++++++++++++
.../hostmetricsreceiver/hostmetrics_linux.go | 2 +-
.../hostmetrics_linux_test.go | 2 +-
3 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 .chloggen/hostmetrics.yaml
diff --git a/.chloggen/hostmetrics.yaml b/.chloggen/hostmetrics.yaml
new file mode 100644
index 000000000000..9abc4630e427
--- /dev/null
+++ b/.chloggen/hostmetrics.yaml
@@ -0,0 +1,27 @@
+# Use this changelog template to create an entry for release notes.
+
+# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
+change_type: bug_fix
+
+# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
+component: hostmetricsreceiver
+
+# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
+note: "Fix filesystem scraper to respect root_path"
+
+# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
+issues: [35990]
+
+# (Optional) One or more lines of additional information to render under the primary note.
+# These lines will be padded with 2 spaces and then inserted directly into the document.
+# Use pipe (|) for multiline entries.
+subtext:
+
+# If your change doesn't affect end users or the exported elements of any package,
+# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
+# Optional: The change log or logs in which this entry should be included.
+# e.g. '[user]' or '[user, api]'
+# Include 'user' if the change is relevant to end users.
+# Include 'api' if there is a change to a library API.
+# Default: '[user]'
+change_logs: [user]
diff --git a/receiver/hostmetricsreceiver/hostmetrics_linux.go b/receiver/hostmetricsreceiver/hostmetrics_linux.go
index 132eb3978d08..bfee8461ab76 100644
--- a/receiver/hostmetricsreceiver/hostmetrics_linux.go
+++ b/receiver/hostmetricsreceiver/hostmetrics_linux.go
@@ -20,7 +20,7 @@ var gopsutilEnvVars = map[common.EnvKeyType]string{
common.HostVarEnvKey: "/var",
common.HostRunEnvKey: "/run",
common.HostDevEnvKey: "/dev",
- common.HostProcMountinfo: "",
+ common.HostProcMountinfo: "/proc/1",
}
// This exists to validate that different instances of the hostmetricsreceiver do not
diff --git a/receiver/hostmetricsreceiver/hostmetrics_linux_test.go b/receiver/hostmetricsreceiver/hostmetrics_linux_test.go
index d6c3cd7f1ad3..d0f6078d90c5 100644
--- a/receiver/hostmetricsreceiver/hostmetrics_linux_test.go
+++ b/receiver/hostmetricsreceiver/hostmetrics_linux_test.go
@@ -52,7 +52,7 @@ func TestLoadConfigRootPath(t *testing.T) {
cpuScraperCfg.SetEnvMap(common.EnvMap{
common.HostDevEnvKey: "testdata/dev",
common.HostEtcEnvKey: "testdata/etc",
- common.HostProcMountinfo: "testdata",
+ common.HostProcMountinfo: "testdata/proc/1",
common.HostRunEnvKey: "testdata/run",
common.HostSysEnvKey: "testdata/sys",
common.HostVarEnvKey: "testdata/var",