diff --git a/exporters/autoexport/metrics.go b/exporters/autoexport/metrics.go index 5b549600832..b8b23e08d80 100644 --- a/exporters/autoexport/metrics.go +++ b/exporters/autoexport/metrics.go @@ -101,10 +101,8 @@ func init() { return nil, err } readerOpts := []metric.PeriodicReaderOption{} - if len(producers) > 0 { - for _, producer := range producers { - readerOpts = append(readerOpts, metric.WithProducer(producer)) - } + for _, producer := range producers { + readerOpts = append(readerOpts, metric.WithProducer(producer)) } proto := os.Getenv(otelExporterOTLPProtoEnvKey) @@ -135,10 +133,8 @@ func init() { return nil, err } readerOpts := []metric.PeriodicReaderOption{} - if len(producers) > 0 { - for _, producer := range producers { - readerOpts = append(readerOpts, metric.WithProducer(producer)) - } + for _, producer := range producers { + readerOpts = append(readerOpts, metric.WithProducer(producer)) } r, err := stdoutmetric.New() @@ -163,10 +159,8 @@ func init() { if err != nil { return nil, err } - if len(producers) > 0 { - for _, producer := range producers { - exporterOpts = append(exporterOpts, promexporter.WithProducer(producer)) - } + for _, producer := range producers { + exporterOpts = append(exporterOpts, promexporter.WithProducer(producer)) } reader, err := promexporter.New(exporterOpts...) diff --git a/exporters/autoexport/noop.go b/exporters/autoexport/noop.go index 3232a5b7f11..7ea4bd69754 100644 --- a/exporters/autoexport/noop.go +++ b/exporters/autoexport/noop.go @@ -57,10 +57,3 @@ func (e noopMetricProducer) Produce(ctx context.Context) ([]metricdata.ScopeMetr func newNoopMetricProducer() noopMetricProducer { return noopMetricProducer{} } - -// IsNoneMetricReader returns true for the exporter returned by [NewMetricReader] -// when OTEL_METRICS_PRODUCERS environment variable is set to "none". -func IsNoneMetricProducer(e metric.Producer) bool { - _, ok := e.(noopMetricProducer) - return ok -}