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 Processes scraper to the Metrics builder #8855

Merged
merged 2 commits into from
Apr 1, 2022
Merged
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
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### 💡 Enhancements 💡

- `cmd/mdatagen`: Add resource attributes definition to metadata.yaml and move `pdata.Metrics` creation to the
generated code (#5270)

### 🛑 Breaking changes 🛑

### 🚩 Deprecations 🚩
Expand All @@ -15,12 +18,12 @@
### 💡 Enhancements 💡

- `k8seventsreceiver`: Add Api_version and resource_version (#8539)
- `cmd/mdatagen`: Add resource attributes definition to metadata.yaml and move `pdata.Metrics` creation to the
generated code (#5270)
- `datadogexporter`: Add `metrics::sums::cumulative_monotonic_mode` to specify export mode for cumulative monotonic sums (#8490)
- `dynatraceexporter`: add multi-instance deployment note to README.md (#8848)
- `resourcedetectionprocessor`: Add attribute allowlist (#8547)
- `datadogexporter`: Metrics payload data and Sketches payload data will be logged if collector is started in debug mode (#8929)
- `cmd/mdatagen`: Add resource attributes definition to metadata.yaml and move `pdata.Metrics` creation to the
generated code (#5270)

### 🛑 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 @@ -84,7 +84,7 @@ func TestLoadConfig(t *testing.T) {
}
return cfg
})(),
processesscraper.TypeStr: &processesscraper.Config{},
processesscraper.TypeStr: (&processesscraper.Factory{}).CreateDefaultConfig(),
pagingscraper.TypeStr: (&pagingscraper.Factory{}).CreateDefaultConfig(),
processscraper.TypeStr: (func() internal.Config {
cfg := (&processscraper.Factory{}).CreateDefaultConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestGatherMetrics_EndToEnd(t *testing.T) {
memoryscraper.TypeStr: scraperFactories[memoryscraper.TypeStr].CreateDefaultConfig(),
networkscraper.TypeStr: scraperFactories[networkscraper.TypeStr].CreateDefaultConfig(),
pagingscraper.TypeStr: scraperFactories[pagingscraper.TypeStr].CreateDefaultConfig(),
processesscraper.TypeStr: &processesscraper.Config{},
processesscraper.TypeStr: scraperFactories[processesscraper.TypeStr].CreateDefaultConfig(),
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@

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

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/processesscraper/internal/metadata"
)

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

// Metrics allows customizing 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 processesscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processesscraper"
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ These are the metrics available for this scraper.
| **system.processes.count** | Total number of processes in each state. | {processes} | Sum(Int) | <ul> <li>status</li> </ul> |
| **system.processes.created** | Total number of created processes. | {processes} | Sum(Int) | <ul> </ul> |

**Highlighted metrics** are emitted by default.
**Highlighted metrics** are emitted by default. Other metrics are optional and not emitted by default.
Any metric can be enabled or disabled with the following scraper configuration:

```yaml
metrics:
<metric_name>:
enabled: <true|false>
```

## Metric attributes

Expand Down
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/processesscraper/internal/metadata"
)

// This file implements Factory for Processes 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 Down

This file was deleted.

Loading