File tree Expand file tree Collapse file tree 2 files changed +12
-26
lines changed
internal/controller/metrics Expand file tree Collapse file tree 2 files changed +12
-26
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ limitations under the License.
1717package metrics
1818
1919import (
20+ "regexp"
21+
2022 "github.com/prometheus/client_golang/prometheus"
2123 "github.com/prometheus/client_golang/prometheus/collectors"
2224 "sigs.k8s.io/controller-runtime/pkg/metrics"
@@ -89,6 +91,13 @@ func init() {
8991 // expose process metrics like CPU, Memory, file descriptor usage etc.
9092 collectors .NewProcessCollector (collectors.ProcessCollectorOpts {}),
9193 // expose Go runtime metrics like GC stats, memory stats etc.
92- collectors .NewGoCollector (),
94+ collectors .NewGoCollector (
95+ collectors .WithGoCollectorRuntimeMetrics (
96+ collectors .MetricsGC ,
97+ collectors .MetricsScheduler ,
98+ collectors .MetricsMemory ,
99+ collectors.GoRuntimeMetricsRule {Matcher : regexp .MustCompile (`^/sync/.*` )},
100+ ),
101+ ),
93102 )
94103}
Original file line number Diff line number Diff line change @@ -16,12 +16,7 @@ limitations under the License.
1616
1717package metrics
1818
19- import (
20- "regexp"
21-
22- "github.com/prometheus/client_golang/prometheus"
23- "github.com/prometheus/client_golang/prometheus/collectors"
24- )
19+ import "github.com/prometheus/client_golang/prometheus"
2520
2621// RegistererGatherer combines both parts of the API of a Prometheus
2722// registry, both the Registerer and the Gatherer interfaces.
@@ -32,22 +27,4 @@ type RegistererGatherer interface {
3227
3328// Registry is a prometheus registry for storing metrics within the
3429// controller-runtime.
35- var Registry RegistererGatherer = NewRegistry ()
36-
37- func NewRegistry () * prometheus.Registry {
38- r := prometheus .NewRegistry ()
39-
40- // default registers
41- r .MustRegister (
42- collectors .NewGoCollector (
43- collectors .WithGoCollectorRuntimeMetrics (
44- collectors .MetricsGC ,
45- collectors .MetricsScheduler ,
46- collectors .MetricsMemory ,
47- collectors.GoRuntimeMetricsRule {Matcher : regexp .MustCompile (`^/sync/.*` )},
48- ),
49- ),
50- collectors .NewProcessCollector (collectors.ProcessCollectorOpts {}),
51- )
52- return r
53- }
30+ var Registry RegistererGatherer = prometheus .NewRegistry ()
You can’t perform that action at this time.
0 commit comments