From f38631504df0c55faca6abb77411f908c70a02c9 Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Mon, 17 Oct 2022 14:15:13 +0000 Subject: [PATCH 1/2] remove prom exporter Describe --- CHANGELOG.md | 1 + exporters/prometheus/exporter.go | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index baab4d165f4..6953e8170b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ 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 a warning on startup. (#????) ### Fixed diff --git a/exporters/prometheus/exporter.go b/exporters/prometheus/exporter.go index 007dc2f50d9..e1fad7e8416 100644 --- a/exporters/prometheus/exporter.go +++ b/exporters/prometheus/exporter.go @@ -68,14 +68,13 @@ func New(opts ...Option) (*Exporter, error) { } // Describe implements prometheus.Collector. +// +// Opentelemetry SDK doesn't have information on which will exist when the collector +// is registered. By returning nothing we are an "unckeched" 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 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 - } } // Collect implements prometheus.Collector. From 377e50a024be980a7b8b248591b6331b54722460 Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Tue, 18 Oct 2022 14:12:06 -0500 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Tyler Yahn --- CHANGELOG.md | 3 ++- exporters/prometheus/exporter.go | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6953e8170b5..f320f102fbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +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 a warning on startup. (#????) +- 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 e1fad7e8416..e14fa3638c6 100644 --- a/exporters/prometheus/exporter.go +++ b/exporters/prometheus/exporter.go @@ -68,13 +68,12 @@ func New(opts ...Option) (*Exporter, error) { } // Describe implements prometheus.Collector. -// -// Opentelemetry SDK doesn't have information on which will exist when the collector -// is registered. By returning nothing we are an "unckeched" 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 func (c *collector) Describe(ch chan<- *prometheus.Desc) { + // 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.