Skip to content

Commit

Permalink
gocollector: Add regex option to allow collection of debug runtime me…
Browse files Browse the repository at this point in the history
…trics

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
  • Loading branch information
Arthur Silva Sens committed Nov 29, 2023
1 parent 80d3f0b commit c9e2565
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions prometheus/collectors/go_collector_latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ var (
// MetricsScheduler allows only scheduler metrics to be collected from Go runtime.
// e.g. go_sched_goroutines_goroutines
MetricsScheduler = GoRuntimeMetricsRule{regexp.MustCompile(`^/sched/.*`)}
// MetricsDebug allows only debug metrics to be collected from Go runtime.
// e.g. go_godebug_non_default_behavior_gocachetest_events_total
MetricsDebug = GoRuntimeMetricsRule{regexp.MustCompile(`^/godebug/.*`)}
)

// WithGoCollectorMemStatsMetricsDisabled disables metrics that is gathered in runtime.MemStats structure such as:
Expand Down
5 changes: 5 additions & 0 deletions prometheus/collectors/go_collector_latest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func TestGoCollectorAllowList(t *testing.T) {
rules: []GoRuntimeMetricsRule{MetricsScheduler},
expected: withSchedulerMetrics(),
},
{
name: "allow debug",
rules: []GoRuntimeMetricsRule{MetricsDebug},
expected: withDebugMetrics(),

Check failure on line 111 in prometheus/collectors/go_collector_latest_test.go

View workflow job for this annotation

GitHub Actions / lint

undefined: withDebugMetrics (typecheck)

Check failure on line 111 in prometheus/collectors/go_collector_latest_test.go

View workflow job for this annotation

GitHub Actions / Tests (1.19)

undefined: withDebugMetrics

Check failure on line 111 in prometheus/collectors/go_collector_latest_test.go

View workflow job for this annotation

GitHub Actions / lint

undefined: withDebugMetrics (typecheck)

Check failure on line 111 in prometheus/collectors/go_collector_latest_test.go

View workflow job for this annotation

GitHub Actions / Tests (1.20)

undefined: withDebugMetrics
},
} {
t.Run(test.name, func(t *testing.T) {
reg := prometheus.NewRegistry()
Expand Down

0 comments on commit c9e2565

Please sign in to comment.