Skip to content

Commit 944984b

Browse files
bwplotkaamberpixels
authored andcommitted
examples: Improved GoCollector example. (prometheus#1589)
Signed-off-by: bwplotka <[email protected]> Signed-off-by: Eugene <[email protected]>
1 parent 474f5cc commit 944984b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

examples/gocollector/main.go

Lines changed: 12 additions & 5 deletions
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)