File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ package collectors
15
15
16
16
import "github.com/prometheus/client_golang/prometheus"
17
17
18
+ type goCollectorOption func (o * prometheus.GoCollectorOptions )
19
+
20
+ func WithTBD () goCollectorOption {
21
+ return func (o * prometheus.GoCollectorOptions ) {
22
+ o .TBD = true
23
+ }
24
+ }
25
+
18
26
// NewGoCollector returns a collector that exports metrics about the current Go
19
27
// process. This includes memory stats. To collect those, runtime.ReadMemStats
20
28
// is called. This requires to “stop the world”, which usually only happens for
@@ -41,9 +49,9 @@ import "github.com/prometheus/client_golang/prometheus"
41
49
//
42
50
// NOTE: The problem is solved in Go 1.15, see
43
51
// https://github.com/golang/go/issues/19812 for the related Go issue.
44
- func NewGoCollector () prometheus.Collector {
52
+ func NewGoCollector (opts ... prometheus. GoCollectorOption ) prometheus.Collector {
45
53
//nolint:staticcheck // Ignore SA1019 until v2.
46
- return prometheus .NewGoCollector ()
54
+ return prometheus .NewGoCollector (opts ... )
47
55
}
48
56
49
57
// NewBuildInfoCollector returns a collector collecting a single metric
Original file line number Diff line number Diff line change @@ -51,11 +51,22 @@ type goCollector struct {
51
51
msMetrics memStatsMetrics
52
52
}
53
53
54
+ type GoCollectorOption func (o * GoCollectorOptions )
55
+
56
+ // GoCollectorOptions should not used be directly by anyone, except `collectors` package.
57
+ // Use it via collectors package instead. See issue why it exists in this package
58
+ // https://github.com/prometheus/client_golang/issues/1030.
59
+ //
60
+ // Deprecated: Use collectors.With
61
+ type GoCollectorOptions struct {
62
+ TBD bool
63
+ }
64
+
54
65
// NewGoCollector is the obsolete version of collectors.NewGoCollector.
55
66
// See there for documentation.
56
67
//
57
68
// Deprecated: Use collectors.NewGoCollector instead.
58
- func NewGoCollector () Collector {
69
+ func NewGoCollector (opts ... GoCollectorOption ) Collector {
59
70
descriptions := metrics .All ()
60
71
61
72
// Collect all histogram samples so that we can get their buckets.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments