Remove deprecated prometheus.InstrumentHandlerFunc (#831)
Update Prometheus client golang use to use `promhttp.Handler()` instead of `prometheus.InstrumentHandlerFunc()`.
This commit is contained in:
parent
7928dc93da
commit
d33a447047
3 changed files with 18 additions and 31 deletions
|
|
@ -56,11 +56,14 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||
registry,
|
||||
}
|
||||
// Delegate http serving to Prometheus client library, which will call collector.Collect.
|
||||
h := promhttp.HandlerFor(gatherers,
|
||||
promhttp.HandlerOpts{
|
||||
ErrorLog: log.NewErrorLogger(),
|
||||
ErrorHandling: promhttp.ContinueOnError,
|
||||
})
|
||||
h := promhttp.InstrumentMetricHandler(
|
||||
registry,
|
||||
promhttp.HandlerFor(gatherers,
|
||||
promhttp.HandlerOpts{
|
||||
ErrorLog: log.NewErrorLogger(),
|
||||
ErrorHandling: promhttp.ContinueOnError,
|
||||
}),
|
||||
)
|
||||
h.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
|
|
@ -88,8 +91,7 @@ func main() {
|
|||
log.Infof(" - %s", n)
|
||||
}
|
||||
|
||||
// TODO(ts): Remove deprecated and problematic InstrumentHandlerFunc usage.
|
||||
http.HandleFunc(*metricsPath, prometheus.InstrumentHandlerFunc("prometheus", handler))
|
||||
http.HandleFunc(*metricsPath, handler)
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte(`<html>
|
||||
<head><title>Node Exporter</title></head>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue