Skip to content

Commit 6dc691e

Browse files
[receiver/hostmetrics] Allow process scraper under FreeBSD (#39622)
#### Description Allow the `process` scraper to be used under FreeBSD for the `hostmetrics` receiver, doing the same handling as done for MacOS. #### Documentation Update the available scrapers table: * added FreeBSD as supported OS for the `process` scraper after the code updates in the PR * added FreeBSD / OpenBSD as supported OSs for the `processes` scraper. Fixed documentation error, since this scraper could already be used in these two OSs
1 parent 01d1160 commit 6dc691e

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
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: enhancement
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: Possible to enable the process scraper under FreeBSD in the hostmetrics receiver.
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: [39622]
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: [user]

receiver/hostmetricsreceiver/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ The available scrapers are:
4747
| [memory] | All | Memory utilization metrics |
4848
| [network] | All | Network interface I/O metrics & TCP connection metrics |
4949
| [paging] | All | Paging/Swap space utilization and I/O metrics |
50-
| [processes] | Linux, Mac | Process count metrics |
51-
| [process] | Linux, Windows, Mac | Per process CPU, Memory, and Disk I/O metrics |
50+
| [processes] | Linux, Mac, FreeBSD, OpenBSD | Process count metrics |
51+
| [process] | Linux, Windows, Mac, FreeBSD | Per process CPU, Memory, and Disk I/O metrics |
5252
| [system] | Linux, Windows, Mac | Miscellaneous system metrics |
5353

5454
[cpu]: ./internal/scraper/cpuscraper/documentation.md

receiver/hostmetricsreceiver/internal/scraper/processscraper/factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func createMetricsScraper(
4444
settings scraper.Settings,
4545
cfg component.Config,
4646
) (scraper.Metrics, error) {
47-
if runtime.GOOS != "linux" && runtime.GOOS != "windows" && runtime.GOOS != "darwin" {
48-
return nil, errors.New("process scraper only available on Linux, Windows, or macOS")
47+
if runtime.GOOS != "linux" && runtime.GOOS != "windows" && runtime.GOOS != "darwin" && runtime.GOOS != "freebsd" {
48+
return nil, errors.New("process scraper only available on Linux, Windows, macOS, or FreeBSD")
4949
}
5050

5151
s, err := newProcessScraper(settings, cfg.(*Config))

receiver/hostmetricsreceiver/internal/scraper/processscraper/factory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestCreateResourceMetricsScraper(t *testing.T) {
2626

2727
scraper, err := factory.CreateMetrics(context.Background(), scrapertest.NewNopSettings(metadata.Type), cfg)
2828

29-
if runtime.GOOS == "linux" || runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
29+
if runtime.GOOS == "linux" || runtime.GOOS == "windows" || runtime.GOOS == "darwin" || runtime.GOOS == "freebsd" {
3030
assert.NoError(t, err)
3131
assert.NotNil(t, scraper)
3232
} else {

receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_darwin.go renamed to receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_bsds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
//go:build darwin
4+
//go:build darwin || freebsd
55

66
package processscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper"
77

receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_others.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
//go:build !linux && !windows && !darwin
4+
//go:build !linux && !windows && !darwin && !freebsd
55

66
package processscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper"
77

0 commit comments

Comments
 (0)