Skip to content

Commit 8e8070b

Browse files
atoulmesbylica-splunk
authored andcommitted
[receiver/hostmetrics] Fix filesystems scraper behavior when root file system is mounted (open-telemetry#36000)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Do not set the default value of HOST_PROC_MOUNTINFO to respect root_path <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#35990
1 parent f31c0d4 commit 8e8070b

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: hostmetricsreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Do not set the default value of HOST_PROC_MOUNTINFO to respect root_path
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [35990]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

receiver/hostmetricsreceiver/hostmetrics_linux.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ import (
1414
)
1515

1616
var gopsutilEnvVars = map[common.EnvKeyType]string{
17-
common.HostProcEnvKey: "/proc",
18-
common.HostSysEnvKey: "/sys",
19-
common.HostEtcEnvKey: "/etc",
20-
common.HostVarEnvKey: "/var",
21-
common.HostRunEnvKey: "/run",
22-
common.HostDevEnvKey: "/dev",
23-
common.HostProcMountinfo: "",
17+
common.HostProcEnvKey: "/proc",
18+
common.HostSysEnvKey: "/sys",
19+
common.HostEtcEnvKey: "/etc",
20+
common.HostVarEnvKey: "/var",
21+
common.HostRunEnvKey: "/run",
22+
common.HostDevEnvKey: "/dev",
2423
}
2524

2625
// This exists to validate that different instances of the hostmetricsreceiver do not

receiver/hostmetricsreceiver/hostmetrics_linux_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ func TestLoadConfigRootPath(t *testing.T) {
5050
cpuScraperCfg := (&cpuscraper.Factory{}).CreateDefaultConfig()
5151
cpuScraperCfg.SetRootPath("testdata")
5252
cpuScraperCfg.SetEnvMap(common.EnvMap{
53-
common.HostDevEnvKey: "testdata/dev",
54-
common.HostEtcEnvKey: "testdata/etc",
55-
common.HostProcMountinfo: "testdata",
56-
common.HostRunEnvKey: "testdata/run",
57-
common.HostSysEnvKey: "testdata/sys",
58-
common.HostVarEnvKey: "testdata/var",
53+
common.HostDevEnvKey: "testdata/dev",
54+
common.HostEtcEnvKey: "testdata/etc",
55+
common.HostRunEnvKey: "testdata/run",
56+
common.HostSysEnvKey: "testdata/sys",
57+
common.HostVarEnvKey: "testdata/var",
5958
})
6059
expectedConfig.Scrapers = map[string]internal.Config{cpuscraper.TypeStr: cpuScraperCfg}
6160

0 commit comments

Comments
 (0)