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/prometheusexec] mark receiver as deprecated #9058

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
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 (#9058)

### 🚀 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)
}