Skip to content

Commit

Permalink
Update hostmetricsreceiver to use scraper.Factory
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Jan 17, 2025
1 parent ad57c0f commit 9fd3047
Show file tree
Hide file tree
Showing 185 changed files with 1,738 additions and 880 deletions.
572 changes: 291 additions & 281 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ body:
- receiver/googlecloudspanner
- receiver/haproxy
- receiver/hostmetrics
- receiver/hostmetrics/internal/scraper/cpuscraper
- receiver/hostmetrics/internal/scraper/diskscraper
- receiver/hostmetrics/internal/scraper/filesystemscraper
- receiver/hostmetrics/internal/scraper/loadscraper
- receiver/hostmetrics/internal/scraper/memoryscraper
- receiver/hostmetrics/internal/scraper/networkscraper
- receiver/hostmetrics/internal/scraper/pagingscraper
- receiver/hostmetrics/internal/scraper/processesscraper
- receiver/hostmetrics/internal/scraper/processscraper
- receiver/hostmetrics/internal/scraper/systemscraper
- receiver/httpcheck
- receiver/huaweicloudces
- receiver/iis
Expand Down
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ body:
- receiver/googlecloudspanner
- receiver/haproxy
- receiver/hostmetrics
- receiver/hostmetrics/internal/scraper/cpuscraper
- receiver/hostmetrics/internal/scraper/diskscraper
- receiver/hostmetrics/internal/scraper/filesystemscraper
- receiver/hostmetrics/internal/scraper/loadscraper
- receiver/hostmetrics/internal/scraper/memoryscraper
- receiver/hostmetrics/internal/scraper/networkscraper
- receiver/hostmetrics/internal/scraper/pagingscraper
- receiver/hostmetrics/internal/scraper/processesscraper
- receiver/hostmetrics/internal/scraper/processscraper
- receiver/hostmetrics/internal/scraper/systemscraper
- receiver/httpcheck
- receiver/huaweicloudces
- receiver/iis
Expand Down
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ body:
- receiver/googlecloudspanner
- receiver/haproxy
- receiver/hostmetrics
- receiver/hostmetrics/internal/scraper/cpuscraper
- receiver/hostmetrics/internal/scraper/diskscraper
- receiver/hostmetrics/internal/scraper/filesystemscraper
- receiver/hostmetrics/internal/scraper/loadscraper
- receiver/hostmetrics/internal/scraper/memoryscraper
- receiver/hostmetrics/internal/scraper/networkscraper
- receiver/hostmetrics/internal/scraper/pagingscraper
- receiver/hostmetrics/internal/scraper/processesscraper
- receiver/hostmetrics/internal/scraper/processscraper
- receiver/hostmetrics/internal/scraper/systemscraper
- receiver/httpcheck
- receiver/huaweicloudces
- receiver/iis
Expand Down
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/unmaintained.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ body:
- receiver/googlecloudspanner
- receiver/haproxy
- receiver/hostmetrics
- receiver/hostmetrics/internal/scraper/cpuscraper
- receiver/hostmetrics/internal/scraper/diskscraper
- receiver/hostmetrics/internal/scraper/filesystemscraper
- receiver/hostmetrics/internal/scraper/loadscraper
- receiver/hostmetrics/internal/scraper/memoryscraper
- receiver/hostmetrics/internal/scraper/networkscraper
- receiver/hostmetrics/internal/scraper/pagingscraper
- receiver/hostmetrics/internal/scraper/processesscraper
- receiver/hostmetrics/internal/scraper/processscraper
- receiver/hostmetrics/internal/scraper/systemscraper
- receiver/httpcheck
- receiver/huaweicloudces
- receiver/iis
Expand Down
2 changes: 2 additions & 0 deletions exporter/datadogexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions receiver/hostmetricsreceiver/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
include ../../Makefile.Common


.PHONY: misspell
misspell:
@echo "cannot run misspell because make[2]: /bin/bash: Argument list too long"
58 changes: 18 additions & 40 deletions receiver/hostmetricsreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
Expand Down Expand Up @@ -42,10 +41,10 @@ func TestLoadConfig(t *testing.T) {
id: component.NewID(metadata.Type),
expected: func() component.Config {
cfg := createDefaultConfig().(*Config)
cpu := cpuscraper.NewFactory()
cfg.Scrapers = map[component.Type]component.Config{
cpuscraper.Type: func() component.Config {
cfg := (&cpuscraper.Factory{}).CreateDefaultConfig()
return cfg
cpu.Type(): func() component.Config {
return cpu.CreateDefaultConfig()
}(),
}
return cfg
Expand All @@ -60,55 +59,34 @@ func TestLoadConfig(t *testing.T) {
InitialDelay: time.Second,
},
Scrapers: map[component.Type]component.Config{
cpuscraper.Type: func() component.Config {
cfg := (&cpuscraper.Factory{}).CreateDefaultConfig()
return cfg
}(),
diskscraper.Type: func() component.Config {
cfg := (&diskscraper.Factory{}).CreateDefaultConfig()
return cfg
}(),
loadscraper.Type: (func() component.Config {
cfg := (&loadscraper.Factory{}).CreateDefaultConfig()
component.MustNewType("cpu"): cpuscraper.NewFactory().CreateDefaultConfig(),
component.MustNewType("disk"): diskscraper.NewFactory().CreateDefaultConfig(),
component.MustNewType("load"): (func() component.Config {
cfg := loadscraper.NewFactory().CreateDefaultConfig()
cfg.(*loadscraper.Config).CPUAverage = true
return cfg
})(),
filesystemscraper.Type: func() component.Config {
cfg := (&filesystemscraper.Factory{}).CreateDefaultConfig()
return cfg
}(),
memoryscraper.Type: func() component.Config {
cfg := (&memoryscraper.Factory{}).CreateDefaultConfig()
return cfg
}(),
networkscraper.Type: (func() component.Config {
cfg := (&networkscraper.Factory{}).CreateDefaultConfig()
component.MustNewType("filesystem"): filesystemscraper.NewFactory().CreateDefaultConfig(),
component.MustNewType("memory"): memoryscraper.NewFactory().CreateDefaultConfig(),
component.MustNewType("network"): (func() component.Config {
cfg := networkscraper.NewFactory().CreateDefaultConfig()
cfg.(*networkscraper.Config).Include = networkscraper.MatchConfig{
Interfaces: []string{"test1"},
Config: filterset.Config{MatchType: "strict"},
}
return cfg
})(),
processesscraper.Type: func() component.Config {
cfg := (&processesscraper.Factory{}).CreateDefaultConfig()
return cfg
}(),
pagingscraper.Type: func() component.Config {
cfg := (&pagingscraper.Factory{}).CreateDefaultConfig()
return cfg
}(),
processscraper.Type: (func() component.Config {
cfg := (&processscraper.Factory{}).CreateDefaultConfig()
component.MustNewType("processes"): processesscraper.NewFactory().CreateDefaultConfig(),
component.MustNewType("paging"): pagingscraper.NewFactory().CreateDefaultConfig(),
component.MustNewType("process"): (func() component.Config {
cfg := processscraper.NewFactory().CreateDefaultConfig()
cfg.(*processscraper.Config).Include = processscraper.MatchConfig{
Names: []string{"test2", "test3"},
Config: filterset.Config{MatchType: "regexp"},
}
return cfg
})(),
systemscraper.Type: (func() component.Config {
cfg := (&systemscraper.Factory{}).CreateDefaultConfig()
return cfg
})(),
component.MustNewType("system"): systemscraper.NewFactory().CreateDefaultConfig(),
},
},
},
Expand All @@ -123,8 +101,8 @@ func TestLoadConfig(t *testing.T) {
require.NoError(t, err)
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
require.NoError(t, component.ValidateConfig(cfg))
require.Equal(t, tt.expected, cfg)
})
}
}
Expand Down
Loading

0 comments on commit 9fd3047

Please sign in to comment.