We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b5c5b8 commit 0b7f488Copy full SHA for 0b7f488
examples/simple/main.go
@@ -18,14 +18,20 @@ import (
18
"flag"
19
"log"
20
"net/http"
21
-
+
22
+ "github.com/prometheus/client_golang/prometheus"
23
"github.com/prometheus/client_golang/prometheus/promhttp"
24
)
25
26
var addr = flag.String("listen-address", ":8080", "The address to listen on for HTTP requests.")
27
28
func main() {
29
flag.Parse()
- http.Handle("/metrics", promhttp.Handler())
30
31
+ // Create non-global registry.
32
+ reg := prometheus.NewRegistry()
33
34
+ // Expose /metrics HTTP endpoint using the created custom registry.
35
+ http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg}))
36
log.Fatal(http.ListenAndServe(*addr, nil))
37
}
0 commit comments