From 14ee7f931d09a7138c89dbf35e57d1168f10fe1f Mon Sep 17 00:00:00 2001 From: Cori1109 Date: Wed, 13 Apr 2022 20:43:29 +0200 Subject: [PATCH] gocollector: Reverted client_golang v1.12 addition of runtime/metrics metrics by default. (#1033) Fixes https://github.com/prometheus/client_golang/issues/967 Signed-off-by: Bartlomiej Plotka --- CHANGELOG.md | 2 ++ prometheus/collectors/go_collector_latest.go | 4 ++-- prometheus/go_collector_latest.go | 2 +- prometheus/go_collector_latest_test.go | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac974ce..d515e69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Unreleased * [CHANGE] Minimum required Go version is now 1.16. +* [CHANGE] Added `collectors.WithGoCollections` that allows to choose what collection of Go runtime metrics user wants: Equivalent of [`MemStats` structure](https://pkg.go.dev/runtime#MemStats) configured using `GoRuntimeMemStatsCollection`, new based on dedicated [runtime/metrics](https://pkg.go.dev/runtime/metrics) metrics represented by `GoRuntimeMetricsCollection` option, or both by specifying `GoRuntimeMemStatsCollection | GoRuntimeMetricsCollection` flag. +* [CHANGE] :warning: Change in `collectors.NewGoCollector` metrics: Reverting addition of new ~80 runtime metrics by default. You can enable this back with `GoRuntimeMetricsCollection` option or `GoRuntimeMemStatsCollection | GoRuntimeMetricsCollection` for smooth transition. ## 1.12.1 / 2022-01-29 diff --git a/prometheus/collectors/go_collector_latest.go b/prometheus/collectors/go_collector_latest.go index a4657a4..58b0a5b 100644 --- a/prometheus/collectors/go_collector_latest.go +++ b/prometheus/collectors/go_collector_latest.go @@ -70,8 +70,8 @@ const ( // WithGoCollections(GoRuntimeMemStatsCollection | GoRuntimeMetricsCollection) means both GoRuntimeMemStatsCollection // metrics and GoRuntimeMetricsCollection will be exposed. // -// Use WithGoCollections(GoRuntimeMemStatsCollection) to have Go collector working in -// the compatibility mode with client_golang pre v1.12 (move to runtime/metrics). +// The current default is GoRuntimeMemStatsCollection, so the compatibility mode with +// client_golang pre v1.12 (move to runtime/metrics). func WithGoCollections(flags uint32) goOption { return func(o *goOptions) { o.EnabledCollections = flags diff --git a/prometheus/go_collector_latest.go b/prometheus/go_collector_latest.go index 944794f..8528ea7 100644 --- a/prometheus/go_collector_latest.go +++ b/prometheus/go_collector_latest.go @@ -132,7 +132,7 @@ func (c GoCollectorOptions) isEnabled(flag uint32) bool { return c.EnabledCollections&flag != 0 } -const defaultGoCollections = goRuntimeMemStatsCollection | goRuntimeMetricsCollection +const defaultGoCollections = goRuntimeMemStatsCollection // NewGoCollector is the obsolete version of collectors.NewGoCollector. // See there for documentation. diff --git a/prometheus/go_collector_latest_test.go b/prometheus/go_collector_latest_test.go index a7fcadd..88158df 100644 --- a/prometheus/go_collector_latest_test.go +++ b/prometheus/go_collector_latest_test.go @@ -117,7 +117,7 @@ func TestGoCollector(t *testing.T) { var sink interface{} func TestBatchHistogram(t *testing.T) { - goMetrics := collectGoMetrics(t, defaultGoCollections) + goMetrics := collectGoMetrics(t, goRuntimeMetricsCollection) var mhist Metric for _, m := range goMetrics {