Skip to content

Commit

Permalink
use feature gate to set default value
Browse files Browse the repository at this point in the history
  • Loading branch information
pokgak committed Nov 9, 2024
1 parent 810c216 commit 69c57e3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion exporter/prometheusremotewriteexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/featuregate"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry"
)
Expand Down Expand Up @@ -85,6 +86,13 @@ type RemoteWriteQueue struct {

var _ component.Config = (*Config)(nil)

var exportCreatedMetricGate = featuregate.GlobalRegistry().MustRegister(
"exporter.prometheusremotewriteexporter.exportCreatedMetric",
featuregate.StageBeta,
featuregate.WithRegisterDescription("Allow enabling the export_created_metric feature."),
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35003"),
)

// Validate checks if the exporter configuration is valid
func (cfg *Config) Validate() error {
if cfg.RemoteWriteQueue.QueueSize < 0 {
Expand All @@ -106,7 +114,7 @@ func (cfg *Config) Validate() error {
}
if cfg.CreatedMetric == nil {
cfg.CreatedMetric = &CreatedMetric{
Enabled: false,
Enabled: exportCreatedMetricGate.IsEnabled(),
}
}
if cfg.MaxBatchSizeBytes < 0 {
Expand Down

0 comments on commit 69c57e3

Please sign in to comment.