Skip to content

Commit 8324e65

Browse files
Dowideit, Sven (O&A, St. Lucia)Dowideit, Sven (O&A, St. Lucia)
authored andcommitted
Add the last few lines needed to show a new user how the Collector/Gatherer fits together
Signed-off-by: Dowideit, Sven (O&A, St. Lucia) <[email protected]>
1 parent 3fb53df commit 8324e65

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

prometheus/example_clustermanager_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313

1414
package prometheus_test
1515

16-
import "github.com/prometheus/client_golang/prometheus"
16+
import (
17+
"log"
18+
"net/http"
19+
20+
"github.com/prometheus/client_golang/prometheus"
21+
"github.com/prometheus/client_golang/prometheus/promhttp"
22+
)
1723

1824
// ClusterManager is an example for a system that might have been built without
1925
// Prometheus in mind. It models a central manager of jobs running in a
@@ -124,4 +130,13 @@ func ExampleCollector() {
124130
// variables to then do something with them.
125131
NewClusterManager("db", reg)
126132
NewClusterManager("ca", reg)
133+
134+
// Add the built in process and golang metrics to this registry
135+
reg.MustRegister(
136+
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
137+
prometheus.NewGoCollector(),
138+
)
139+
140+
http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))
141+
log.Fatal(http.ListenAndServe(":8080", nil))
127142
}

0 commit comments

Comments
 (0)