Skip to content

Commit

Permalink
[receiver/hostmetrics] Migrate Processes scraper to the Metrics build…
Browse files Browse the repository at this point in the history
…er (#8855)

* [receiver/hostmetrics] Migrate Processes scraper to the Metrics builder

* Move changelog entry to unreleased

Signed-off-by: Juraci Paixão Kröhling <[email protected]>

Co-authored-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
dmitryax and jpkrohling authored Apr 1, 2022
1 parent 4324ee2 commit 7692d05
Show file tree
Hide file tree
Showing 11 changed files with 324 additions and 187 deletions.
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 🛑

- `filelogreceiver`, `journaldreceiver`, `syslogreceiver`, `tcplogreceiver`, `udplogreceiver`:
Expand All @@ -30,12 +33,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
2 changes: 1 addition & 1 deletion receiver/hostmetricsreceiver/hostmetrics_receiver_test.go
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

0 comments on commit 7692d05

Please sign in to comment.