Skip to content

Commit

Permalink
[receiver/prometheusexec] mark receiver as deprecated (#9058)
Browse files Browse the repository at this point in the history
* [receiver/prometheusexec] mark receiver as deprecated

After many discussions it seems the community is leaning towards removing the components that execute subprocesses. As such, marking the prom_exec receiver as deprecated.

Fixes #6722

* Update CHANGELOG.md

Co-authored-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
Alex Boten and jpkrohling committed Apr 6, 2022
1 parent 4c48a85 commit a434fd3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- `datadogexporter`: Deprecate `service` setting in favor of `service.name` semantic convention (#8784)
- `datadogexporter`: Deprecate `version` setting in favor of `service.version` semantic convention (#8784)
- `datadogexporter`: Deprecate `GetHostTags` method from `TagsConfig` struct (#8975)
- `prometheusexecreceiver`: Deprecate prom_exec receiver (#9058)
- `fluentbitextension`: Deprecate Fluentbit extension (#9062)

### 🚀 New components 🚀
Expand Down
5 changes: 4 additions & 1 deletion receiver/prometheusexecreceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# prometheus_exec Receiver
# Deprecated prometheus_exec Receiver

This receiver has been deprecated due to security concerns around the ability to specify the execution of
any arbitrary processes via its configuration. See [#6722](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/6722) for additional details.

This receiver makes it easy for a user to collect metrics from third-party
services **via Prometheus exporters**. It's meant for people who want a
Expand Down
11 changes: 11 additions & 0 deletions receiver/prometheusexecreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ package prometheusexecreceiver // import "github.com/open-telemetry/opentelemetr

import (
"context"
"sync"
"time"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusexecreceiver/subprocessmanager"
)
Expand All @@ -34,6 +36,8 @@ const (
defaultTimeoutInterval = 10 * time.Second
)

var once sync.Once

// NewFactory creates a factory for the prometheusexec receiver
func NewFactory() component.ReceiverFactory {
return component.NewReceiverFactory(
Expand All @@ -42,6 +46,12 @@ func NewFactory() component.ReceiverFactory {
component.WithMetricsReceiver(createMetricsReceiver))
}

func logDeprecation(logger *zap.Logger) {
once.Do(func() {
logger.Warn("prometheus_exec receiver is deprecated and will be removed in future versions.")
})
}

// createDefaultConfig returns a default config
func createDefaultConfig() config.Receiver {
return &Config{
Expand All @@ -61,6 +71,7 @@ func createMetricsReceiver(
cfg config.Receiver,
nextConsumer consumer.Metrics,
) (component.MetricsReceiver, error) {
logDeprecation(params.Logger)
rCfg := cfg.(*Config)
return newPromExecReceiver(params, rCfg, nextConsumer)
}

0 comments on commit a434fd3

Please sign in to comment.