mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-17 10:09:05 +02:00
httphandler: expose Go scheduler metrics (#2561)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9c3aa2d977
commit
301eef493b
@@ -23,6 +23,7 @@ import (
|
||||
"log/slog"
|
||||
"math"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -80,7 +81,13 @@ func New(logger *slog.Logger, metricCollectors *collector.Collection, options *O
|
||||
handler.exporterMetricsRegistry.MustRegister(
|
||||
collectors.NewBuildInfoCollector(),
|
||||
collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}),
|
||||
collectors.NewGoCollector(),
|
||||
collectors.NewGoCollector(
|
||||
// Goroutine states, goroutines created, runtime threads and scheduler latency
|
||||
// help to spot goroutine leaks and CPU starvation of the exporter.
|
||||
collectors.WithGoCollectorRuntimeMetrics(collectors.GoRuntimeMetricsRule{
|
||||
Matcher: regexp.MustCompile(`^/sched/(goroutines(-created)?|goroutines/[a-z-]+|threads/total|latencies):`),
|
||||
}),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ func TestMetricsHTTPHandler(t *testing.T) {
|
||||
included []string
|
||||
excluded []string
|
||||
}{
|
||||
{name: "default", status: http.StatusOK, included: []string{"windows_test_first 42", "windows_test_second 42", "go_goroutines", "windows_exporter_build_info"}},
|
||||
{name: "disable exporter metrics", options: &httphandler.Options{DisableExporterMetrics: true, TimeoutMargin: 0.5}, status: http.StatusOK, included: []string{"windows_test_first 42", "windows_exporter_build_info"}, excluded: []string{"go_goroutines", "process_cpu_seconds_total"}},
|
||||
{name: "default", status: http.StatusOK, included: []string{"windows_test_first 42", "windows_test_second 42", "go_goroutines", "windows_exporter_build_info", "go_sched_goroutines_running_goroutines", "go_sched_goroutines_waiting_goroutines", "go_sched_goroutines_created_goroutines_total", "go_sched_threads_total_threads", "go_sched_latencies_seconds_bucket"}},
|
||||
{name: "disable exporter metrics", options: &httphandler.Options{DisableExporterMetrics: true, TimeoutMargin: 0.5}, status: http.StatusOK, included: []string{"windows_test_first 42", "windows_exporter_build_info"}, excluded: []string{"go_goroutines", "process_cpu_seconds_total", "go_sched_goroutines_running_goroutines"}},
|
||||
{name: "filter", query: "?collect[]=first", status: http.StatusOK, included: []string{"windows_test_first 42"}, excluded: []string{"windows_test_second"}},
|
||||
{name: "multiple collectors", query: "?collect[]=first&collect[]=second", status: http.StatusOK, included: []string{"windows_test_first 42", "windows_test_second 42"}},
|
||||
{name: "unknown collector", query: "?collect[]=missing", status: http.StatusBadRequest, included: []string{"unknown collector missing"}},
|
||||
|
||||
Reference in New Issue
Block a user