Skip to content

Commit fa4f164

Browse files
authored
examples: Improved GoCollector example. (#1589)
Signed-off-by: bwplotka <[email protected]>
1 parent 30da80d commit fa4f164

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Diff for: examples/gocollector/main.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,18 @@ func main() {
3737
// Create a new registry.
3838
reg := prometheus.NewRegistry()
3939

40-
// Add Go module build info.
41-
reg.MustRegister(collectors.NewBuildInfoCollector())
42-
reg.MustRegister(collectors.NewGoCollector(
43-
collectors.WithGoCollectorRuntimeMetrics(collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")}),
44-
))
40+
// Register metrics from GoCollector collecting statistics from the Go Runtime.
41+
// This enabled default, recommended metrics with the additional, recommended metric for
42+
// goroutine scheduling latencies histogram that is currently bit too expensive for default option.
43+
//
44+
// See the related GopherConUK talk to learn more: https://www.youtube.com/watch?v=18dyI_8VFa0
45+
reg.MustRegister(
46+
collectors.NewGoCollector(
47+
collectors.WithGoCollectorRuntimeMetrics(
48+
collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/sched/latencies:seconds")},
49+
),
50+
),
51+
)
4552

4653
// Expose the registered metrics via HTTP.
4754
http.Handle("/metrics", promhttp.HandlerFor(

0 commit comments

Comments
 (0)