diff --git a/CHANGELOG.md b/CHANGELOG.md index c7d998065a2..e81ccaf4f46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `sdktrace.TraceProvider.Shutdown` and `sdktrace.TraceProvider.ForceFlush` to not return error when no processor register. (#3268) - The `"go.opentelemetry.io/otel/exporters/prometheus".New` now also returns an error indicating the failure to register the exporter with Prometheus. (#3239) +- The prometheus exporter will no longer try to enumerate the metrics it will send to prometheus on startup. + This fixes the `reader is not registered` warning currently emitted on startup. (#3291 #3342) ### Fixed diff --git a/exporters/prometheus/exporter.go b/exporters/prometheus/exporter.go index 007dc2f50d9..e14fa3638c6 100644 --- a/exporters/prometheus/exporter.go +++ b/exporters/prometheus/exporter.go @@ -69,13 +69,11 @@ func New(opts ...Option) (*Exporter, error) { // Describe implements prometheus.Collector. func (c *collector) Describe(ch chan<- *prometheus.Desc) { - metrics, err := c.reader.Collect(context.TODO()) - if err != nil { - otel.Handle(err) - } - for _, metricData := range getMetricData(metrics) { - ch <- metricData.description - } + // The Opentelemetry SDK doesn't have information on which will exist when the collector + // is registered. By returning nothing we are an "unchecked" collector in Prometheus, + // and assume responsibility for consistency of the metrics produced. + // + // See https://pkg.go.dev/github.com/prometheus/client_golang@v1.13.0/prometheus#hdr-Custom_Collectors_and_constant_Metrics } // Collect implements prometheus.Collector.