Skip to content

Commit 0e582c6

Browse files
author
Arthur Silva Sens
committed
gocollector: Add regex option to allow collection of debug runtime metrics
Signed-off-by: Arthur Silva Sens <[email protected]>
1 parent 80d3f0b commit 0e582c6

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

prometheus/collectors/go_collector_go117_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,7 @@ func withSchedulerMetrics() []string {
9898
"go_threads",
9999
}
100100
}
101+
102+
func withDebugMetrics() []string {
103+
return []string{}
104+
}

prometheus/collectors/go_collector_go119_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,7 @@ func withSchedulerMetrics() []string {
105105
"go_threads",
106106
}
107107
}
108+
109+
func withDebugMetrics() []string {
110+
return []string{}
111+
}

prometheus/collectors/go_collector_go120_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,7 @@ func withSchedulerMetrics() []string {
117117
"go_threads",
118118
}
119119
}
120+
121+
func withDebugMetrics() []string {
122+
return []string{}
123+
}

prometheus/collectors/go_collector_latest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ var (
3737
// MetricsScheduler allows only scheduler metrics to be collected from Go runtime.
3838
// e.g. go_sched_goroutines_goroutines
3939
MetricsScheduler = GoRuntimeMetricsRule{regexp.MustCompile(`^/sched/.*`)}
40+
// MetricsDebug allows only debug metrics to be collected from Go runtime.
41+
// e.g. go_godebug_non_default_behavior_gocachetest_events_total
42+
MetricsDebug = GoRuntimeMetricsRule{regexp.MustCompile(`^/godebug/.*`)}
4043
)
4144

4245
// WithGoCollectorMemStatsMetricsDisabled disables metrics that is gathered in runtime.MemStats structure such as:

prometheus/collectors/go_collector_latest_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ func TestGoCollectorAllowList(t *testing.T) {
105105
rules: []GoRuntimeMetricsRule{MetricsScheduler},
106106
expected: withSchedulerMetrics(),
107107
},
108+
{
109+
name: "allow debug",
110+
rules: []GoRuntimeMetricsRule{MetricsDebug},
111+
expected: withDebugMetrics(),
112+
},
108113
} {
109114
t.Run(test.name, func(t *testing.T) {
110115
reg := prometheus.NewRegistry()

0 commit comments

Comments
 (0)