Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/hostmetrics] Migrate memory scraper to the new metrics builder #7421

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- `postgresreceiver`: Update to mdatagen v2 (#7503)
- `nginxreceiver`: Update to mdatagen v2 (#7549)
- `datadogexporter`: Fix traces exporter's initialization log (#7564)
- `hostreceiver/memoryscraper`: Migrate the scraper to the mdatagen metrics builder (#7421)
- `tailsamplingprocessor`: Add And sampling policy (#6910)

## 🛑 Breaking changes 🛑
Expand Down
2 changes: 1 addition & 1 deletion receiver/hostmetricsreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestLoadConfig(t *testing.T) {
return cfg
})(),
filesystemscraper.TypeStr: &filesystemscraper.Config{},
memoryscraper.TypeStr: &memoryscraper.Config{},
memoryscraper.TypeStr: (&memoryscraper.Factory{}).CreateDefaultConfig(),
networkscraper.TypeStr: (func() internal.Config {
cfg := (&networkscraper.Factory{}).CreateDefaultConfig()
cfg.(*networkscraper.Config).Include = networkscraper.MatchConfig{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestGatherMetrics_EndToEnd(t *testing.T) {
diskscraper.TypeStr: scraperFactories[diskscraper.TypeStr].CreateDefaultConfig(),
filesystemscraper.TypeStr: &filesystemscraper.Config{},
loadscraper.TypeStr: scraperFactories[loadscraper.TypeStr].CreateDefaultConfig(),
memoryscraper.TypeStr: &memoryscraper.Config{},
memoryscraper.TypeStr: scraperFactories[memoryscraper.TypeStr].CreateDefaultConfig(),
networkscraper.TypeStr: scraperFactories[networkscraper.TypeStr].CreateDefaultConfig(),
pagingscraper.TypeStr: &pagingscraper.Config{},
processesscraper.TypeStr: &processesscraper.Config{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@

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

import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal"
import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/internal/metadata"
)

// Config relating to Memory Metric Scraper.
type Config struct {
internal.ConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct

// Metrics allows to customize scraped metrics representation.
Metrics metadata.MetricsSettings `mapstructure:"metrics"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
//go:build !windows
// +build !windows

//go:generate mdatagen metadata.yaml
//go:generate mdatagen --experimental-gen metadata.yaml

package memoryscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/memoryscraper"
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/internal/metadata"
)

// This file implements Factory for Memory scraper.
Expand All @@ -36,7 +37,9 @@ type Factory struct {

// CreateDefaultConfig creates the default configuration for the Scraper.
func (f *Factory) CreateDefaultConfig() internal.Config {
return &Config{}
return &Config{
Metrics: metadata.DefaultMetricsSettings(),
}
}

// CreateMetricsScraper creates a scraper based on provided config.
Expand All @@ -48,5 +51,8 @@ func (f *Factory) CreateMetricsScraper(
cfg := config.(*Config)
s := newMemoryScraper(ctx, cfg)

return scraperhelper.NewScraper(TypeStr, s.Scrape)
return scraperhelper.NewScraper(TypeStr,
s.scrape,
scraperhelper.WithStart(s.start),
)
}

This file was deleted.

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

Loading