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 <bwplotka@gmail.com>
This commit is contained in:
Bartlomiej Plotka 2022-04-13 20:43:29 +02:00 committed by GitHub
parent cd90f33be8
commit 11ee9add27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,8 @@
## Unreleased ## Unreleased
* [CHANGE] Minimum required Go version is now 1.16. * [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 ## 1.12.1 / 2022-01-29

View File

@ -70,8 +70,8 @@ const (
// WithGoCollections(GoRuntimeMemStatsCollection | GoRuntimeMetricsCollection) means both GoRuntimeMemStatsCollection // WithGoCollections(GoRuntimeMemStatsCollection | GoRuntimeMetricsCollection) means both GoRuntimeMemStatsCollection
// metrics and GoRuntimeMetricsCollection will be exposed. // metrics and GoRuntimeMetricsCollection will be exposed.
// //
// Use WithGoCollections(GoRuntimeMemStatsCollection) to have Go collector working in // The current default is GoRuntimeMemStatsCollection, so the compatibility mode with
// the compatibility mode with client_golang pre v1.12 (move to runtime/metrics). // client_golang pre v1.12 (move to runtime/metrics).
func WithGoCollections(flags uint32) goOption { func WithGoCollections(flags uint32) goOption {
return func(o *goOptions) { return func(o *goOptions) {
o.EnabledCollections = flags o.EnabledCollections = flags

View File

@ -132,7 +132,7 @@ func (c GoCollectorOptions) isEnabled(flag uint32) bool {
return c.EnabledCollections&flag != 0 return c.EnabledCollections&flag != 0
} }
const defaultGoCollections = goRuntimeMemStatsCollection | goRuntimeMetricsCollection const defaultGoCollections = goRuntimeMemStatsCollection
// NewGoCollector is the obsolete version of collectors.NewGoCollector. // NewGoCollector is the obsolete version of collectors.NewGoCollector.
// See there for documentation. // See there for documentation.

View File

@ -117,7 +117,7 @@ func TestGoCollector(t *testing.T) {
var sink interface{} var sink interface{}
func TestBatchHistogram(t *testing.T) { func TestBatchHistogram(t *testing.T) {
goMetrics := collectGoMetrics(t, defaultGoCollections) goMetrics := collectGoMetrics(t, goRuntimeMetricsCollection)
var mhist Metric var mhist Metric
for _, m := range goMetrics { for _, m := range goMetrics {