Skip to content

Commit

Permalink
Add Go GC metrics to admin endpoint default
Browse files Browse the repository at this point in the history
Add Go `runtime/metrics` path `/gc/` to the default included metrics.

This will add several new metrics and about 80 additional series per
process:
* `go_gc_cycles_automatic_gc_cycles_total`
* `go_gc_cycles_forced_gc_cycles_total`
* `go_gc_cycles_total_gc_cycles_total`
* `go_gc_heap_allocs_by_size_bytes_bucket`
* `go_gc_heap_allocs_by_size_bytes_count`
* `go_gc_heap_allocs_by_size_bytes_sum`
* `go_gc_heap_allocs_bytes_total`
* `go_gc_heap_allocs_objects_total`
* `go_gc_heap_frees_by_size_bytes_bucket`
* `go_gc_heap_frees_by_size_bytes_count`
* `go_gc_heap_frees_by_size_bytes_sum`
* `go_gc_heap_frees_bytes_total`
* `go_gc_heap_frees_objects_total`
* `go_gc_heap_goal_bytes`
* `go_gc_heap_objects_objects`
* `go_gc_heap_tiny_allocs_objects_total`
* `go_gc_limiter_last_enabled_gc_cycle`
* `go_gc_pauses_seconds_bucket`
* `go_gc_pauses_seconds_count`
* `go_gc_pauses_seconds_sum`
* `go_gc_stack_starting_size_bytes`

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ committed Mar 12, 2024
1 parent 00f31e5 commit 6e3f72c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/admin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
var Mux = http.NewServeMux()

var baseplateGoCollectors = collectors.WithGoCollectorRuntimeMetrics(
collectors.MetricsGC,
collectors.MetricsScheduler,
)

Expand Down
22 changes: 22 additions & 0 deletions internal/admin/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,29 @@ import (
)

var expectedMetrics = []string{
"go_gc_cycles_automatic_gc_cycles_total",
"go_gc_cycles_forced_gc_cycles_total",
"go_gc_cycles_total_gc_cycles_total",
"go_gc_duration_seconds",
"go_gc_gogc_percent",
"go_gc_gomemlimit_bytes",
"go_gc_heap_allocs_by_size_bytes",
"go_gc_heap_allocs_bytes_total",
"go_gc_heap_allocs_objects_total",
"go_gc_heap_frees_by_size_bytes",
"go_gc_heap_frees_bytes_total",
"go_gc_heap_frees_objects_total",
"go_gc_heap_goal_bytes",
"go_gc_heap_live_bytes",
"go_gc_heap_objects_objects",
"go_gc_heap_tiny_allocs_objects_total",
"go_gc_limiter_last_enabled_gc_cycle",
"go_gc_pauses_seconds",
"go_gc_scan_globals_bytes",
"go_gc_scan_heap_bytes",
"go_gc_scan_stack_bytes",
"go_gc_scan_total_bytes",
"go_gc_stack_starting_size_bytes",
"go_goroutines",
"go_info",
"go_memstats_alloc_bytes",
Expand Down

0 comments on commit 6e3f72c

Please sign in to comment.