Skip to content

Commit

Permalink
[receiver/prometheusexec] mark receiver as deprecated
Browse files Browse the repository at this point in the history
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 open-telemetry#6722
  • Loading branch information
Alex Boten committed Mar 31, 2022
1 parent 32f6541 commit b8311bd
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 @@ -18,6 +18,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 ()

### 🚀 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 b8311bd

Please sign in to comment.