Update simple example to use custom registry
Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>
This commit is contained in:
parent
9b5c5b8a47
commit
0b7f4888b0
|
@ -18,7 +18,8 @@ import (
|
|||
"flag"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
|
@ -26,6 +27,11 @@ var addr = flag.String("listen-address", ":8080", "The address to listen on for
|
|||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
|
||||
// Create non-global registry.
|
||||
reg := prometheus.NewRegistry()
|
||||
|
||||
// Expose /metrics HTTP endpoint using the created custom registry.
|
||||
http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg}))
|
||||
log.Fatal(http.ListenAndServe(*addr, nil))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue