Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion prometheus/example_clustermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@

package prometheus_test

import "github.com/prometheus/client_golang/prometheus"
import (
"log"
"net/http"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

// ClusterManager is an example for a system that might have been built without
// Prometheus in mind. It models a central manager of jobs running in a
Expand Down Expand Up @@ -124,4 +130,13 @@ func ExampleCollector() {
// variables to then do something with them.
NewClusterManager("db", reg)
NewClusterManager("ca", reg)

// Add the built in process and golang metrics to this registry
reg.MustRegister(
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
prometheus.NewGoCollector(),
)

http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))
log.Fatal(http.ListenAndServe(":8080", nil))
}