Skip to content

Commit

Permalink
move to non default prometheus registry
Browse files Browse the repository at this point in the history
  • Loading branch information
dwillcocks committed Apr 23, 2021
1 parent 1bdce9e commit bf0d0d4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/starlink_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func main() {
}
defer exporter.Conn.Close()

prometheus.MustRegister(exporter)
r := prometheus.NewRegistry()
r.MustRegister(exporter)

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(`<html>
Expand Down Expand Up @@ -54,6 +55,6 @@ func main() {
_, _ = fmt.Fprintf(w, "%s\n", exporter.Conn.GetState())
})

http.Handle(metricsPath, promhttp.Handler())
http.Handle(metricsPath, promhttp.HandlerFor(r, promhttp.HandlerOpts{}))
log.Fatal(http.ListenAndServe(":"+*port, nil))
}

0 comments on commit bf0d0d4

Please sign in to comment.