@@ -109,8 +109,36 @@ func WithoutGoCollectorRuntimeMetrics(matchers ...*regexp.Regexp) func(options *
109109 }
110110}
111111
112+ // GoCollectionOption represents Go collection option flag.
113+ // Deprecated.
114+ type GoCollectionOption uint32
115+
116+ const (
117+ // GoRuntimeMemStatsCollection represents the metrics represented by runtime.MemStats structure.
118+ // Deprecated. Use WithGoCollectorMemStatsMetricsDisabled() function to disable those metrics in the collector.
119+ GoRuntimeMemStatsCollection GoCollectionOption = 1 << iota
120+ // GoRuntimeMetricsCollection is the new set of metrics represented by runtime/metrics package.
121+ // Deprecated. Use WithGoCollectorRuntimeMetrics(GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")})
122+ // function to enable those metrics in the collector.
123+ GoRuntimeMetricsCollection
124+ )
125+
126+ // WithGoCollections allows enabling different collections for Go collector on top of base metrics.
127+ // Deprecated. Use WithGoCollectorRuntimeMetrics() and WithGoCollectorMemStatsMetricsDisabled() instead to control metrics.
128+ func WithGoCollections (flags GoCollectionOption ) func (options * internal.GoCollectorOptions ) {
129+ return func (options * internal.GoCollectorOptions ) {
130+ if flags & GoRuntimeMemStatsCollection == 0 {
131+ WithGoCollectorMemStatsMetricsDisabled ()(options )
132+ }
133+
134+ if flags & GoRuntimeMetricsCollection != 0 {
135+ WithGoCollectorRuntimeMetrics (GoRuntimeMetricsRule {Matcher : regexp .MustCompile ("/.*" )})(options )
136+ }
137+ }
138+ }
139+
112140// NewGoCollector returns a collector that exports metrics about the current Go
113- // process using debug.GCStats and runtime/metrics.
141+ // process using debug.GCStats (base metrics) and runtime/metrics (both in MemStats style and new ones) .
114142func NewGoCollector (opts ... func (o * internal.GoCollectorOptions )) prometheus.Collector {
115143 //nolint:staticcheck // Ignore SA1019 until v2.
116144 return prometheus .NewGoCollector (opts ... )
0 commit comments