Skip to content

Commit

Permalink
[receiver/dockerstats] remove old scraper implementation (#18449)
Browse files Browse the repository at this point in the history
* remove featuregate and old scraper implementation

* add changelog

* change to breaking
  • Loading branch information
jamesmoessis authored Feb 8, 2023
1 parent c882744 commit e506d19
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 973 deletions.
4 changes: 4 additions & 0 deletions .chloggen/remove-dockerstats-featuregate-v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
change_type: breaking
component: dockerstatsreceiver
note: Removed the deprecated scraper implementation which was toggled by the featuregate `receiver.dockerstats.useScraperV2`.
issues: [18449, 9794]
25 changes: 9 additions & 16 deletions receiver/dockerstatsreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ only unmatched container image names should be monitored.
`!/my?egex/` will monitor all containers whose name doesn't match the compiled regex `my?egex`.
- Globs are non-regex items (e.g. `/items/`) containing any of the following: `*[]{}?`. Negations are supported:
`!my*container` will monitor all containers whose image name doesn't match the blob `my*container`.
- `provide_per_core_cpu_metrics` (default = `false`): Whether to report `cpu.usage.percpu` metrics.
- `timeout` (default = `5s`): The request timeout for any docker daemon query.
- `api_version` (default = `1.22`): The Docker client API version (must be 1.22+). [Docker API versions](https://docs.docker.com/engine/api/).
- `metrics` (defaults at [./documentation.md](./documentation.md)): Enables/disables individual metrics. See [./documentation.md](./documentation.md) for full detail.

Example:

Expand All @@ -57,7 +57,11 @@ receivers:
- undesired-container
- /.*undesired.*/
- another-*-container
provide_per_core_cpu_metrics: true
metrics:
container.cpu.usage.percpu:
enabled: true
container.network.io.usage.tx_dropped:
enabled: false
```
The full list of settings exposed for this receiver are documented [here](./config.go)
Expand All @@ -66,26 +70,15 @@ with detailed sample configurations [here](./testdata/config.yaml).
[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
## Feature Gates
See the [Collector feature gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md#collector-feature-gates) for an overview of feature gates in the collector.
**STABLE**: `receiver.dockerstats.useScraperV2`

The feature gate `receiver.dockerstats.useScraperV2` allows collection of selective metrics that is described in [documentation.md](./documentation.md). When the feature gate is disabled, the metrics settings are mostly ignored and not configurable with minor variation in metric name and attributes.

This is considered a breaking change for existing users of this receiver, and it is recommended to migrate to the new implementation when possible. Leave this feature gate enabled to avoid having to migrate any visualisations or alerts.

This feature gate is enabled by default, and eventually the old implementation will be removed (aiming for 0.71.0).

### Migrating from ScraperV1 to ScraperV2
*Note: These changes are now in effect and ScraperV1 have been removed as of v0.71.*
There are some breaking changes from ScraperV1 to ScraperV2. The work done for these changes is tracked in [#9794](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/9794).
| Breaking Change | Action |
|-------------------------------------|-------------------------------------------------------------------------|
| Many metrics are no longer emitted by default. | See [documentation.md](./documentation.md) to see which metrics are enabled by default. Enable/disable as desired. |
| BlockIO metrics names changed. The type of operation is no longer in the metric name suffix, and is now in an attribute. For example `container.blockio.io_merged_recursive.read` becomes `container.blockio.io_merged_recursive` with an `operation:read` attribute. | Be aware of the metric name changes and make any adjustments to what your downstream expects from BlockIO metrics. |
| Memory metrics measured in Bytes are now [non-monotonic sums](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md#opentelemetry-protocol-data-model-consumer-recommendations) instead of gauges. | Most likely there is no action. The aggregation type is different but the values are the same. Be aware of how your downstream handles gauges vs non-monotonic sums. |
| Config option `provide_per_core_cpu_metrics` will be deprecated and removed. | Enable the `container.cpu.usage.percpu` metric as per [documentation.md](./documentation.md). |
| Config option `provide_per_core_cpu_metrics` has been removed. | Enable the `container.cpu.usage.percpu` metric as per [documentation.md](./documentation.md). |
3 changes: 0 additions & 3 deletions receiver/dockerstatsreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ type Config struct {
// A list of filters whose matching images are to be excluded. Supports literals, globs, and regex.
ExcludedImages []string `mapstructure:"excluded_images"`

// Whether to report all CPU metrics. Default is false
ProvidePerCoreCPUMetrics bool `mapstructure:"provide_per_core_cpu_metrics"`

// Docker client API version. Default is 1.22
DockerAPIVersion float64 `mapstructure:"api_version"`

Expand Down
1 change: 0 additions & 1 deletion receiver/dockerstatsreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func TestLoadConfig(t *testing.T) {
Timeout: 20 * time.Second,
DockerAPIVersion: 1.24,

ProvidePerCoreCPUMetrics: true,
ExcludedImages: []string{
"undesired-container",
"another-*-container",
Expand Down
16 changes: 3 additions & 13 deletions receiver/dockerstatsreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ const (
stability = component.StabilityLevelAlpha
)

var useScraperV2 = featuregate.GlobalRegistry().MustRegister(
var _ = featuregate.GlobalRegistry().MustRegister(
"receiver.dockerstats.useScraperV2",
featuregate.StageStable,
featuregate.WithRegisterDescription("When enabled, the receiver will use the function ScrapeV2 to collect metrics. This allows each metric to be turned off/on via config. The new metrics are slightly different to the legacy implementation."),
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/9794"),
featuregate.WithRegisterRemovalVersion("0.71.0"),
featuregate.WithRegisterRemovalVersion("0.74.0"),
)

func NewFactory() rcvr.Factory {
Expand Down Expand Up @@ -68,17 +68,7 @@ func createMetricsReceiver(
dockerConfig := config.(*Config)
dsr := newReceiver(params, dockerConfig)

scrapeFunc := dsr.scrape
if useScraperV2.IsEnabled() {
scrapeFunc = dsr.scrapeV2
} else {
params.Logger.Warn(
"You are using the deprecated ScraperV1, which will " +
"be disabled by default in an upcoming release." +
"See the dockerstatsreceiver/README.md for more info.")
}

scrp, err := scraperhelper.NewScraper(typeStr, scrapeFunc, scraperhelper.WithStart(dsr.start))
scrp, err := scraperhelper.NewScraper(typeStr, dsr.scrapeV2, scraperhelper.WithStart(dsr.start))
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion receiver/dockerstatsreceiver/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func TestAllMetricsIntegration(t *testing.T) {

consumer := new(consumertest.MetricsSink)
f, config := factory()
config.ProvidePerCoreCPUMetrics = true

params, ctx, cancel := paramsAndContext(t)
defer cancel()
Expand Down
Loading

0 comments on commit e506d19

Please sign in to comment.