aboutsummaryrefslogtreecommitdiff
path: root/node_exporter.go
diff options
context:
space:
mode:
authorBen Kochie <superq@gmail.com>2018-02-19 15:44:59 +0100
committerGitHub <noreply@github.com>2018-02-19 15:44:59 +0100
commitd33a447047f2f98eab5c500017da159fd545b9b6 (patch)
tree29371bc8fcb7624e6edf5fe4630f822c28d134b5 /node_exporter.go
parent7928dc93da6838c27fc2569005e7f7cb2e2782d9 (diff)
downloadprometheus_node_collector-d33a447047f2f98eab5c500017da159fd545b9b6.tar.bz2
prometheus_node_collector-d33a447047f2f98eab5c500017da159fd545b9b6.tar.xz
prometheus_node_collector-d33a447047f2f98eab5c500017da159fd545b9b6.zip
Remove deprecated prometheus.InstrumentHandlerFunc (#831)
Update Prometheus client golang use to use `promhttp.Handler()` instead of `prometheus.InstrumentHandlerFunc()`.
Diffstat (limited to 'node_exporter.go')
-rw-r--r--node_exporter.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/node_exporter.go b/node_exporter.go
index 7c1958e..b2884c3 100644
--- a/node_exporter.go
+++ b/node_exporter.go
@@ -56,11 +56,14 @@ func handler(w http.ResponseWriter, r *http.Request) {
56 registry, 56 registry,
57 } 57 }
58 // Delegate http serving to Prometheus client library, which will call collector.Collect. 58 // Delegate http serving to Prometheus client library, which will call collector.Collect.
59 h := promhttp.HandlerFor(gatherers, 59 h := promhttp.InstrumentMetricHandler(
60 promhttp.HandlerOpts{ 60 registry,
61 ErrorLog: log.NewErrorLogger(), 61 promhttp.HandlerFor(gatherers,
62 ErrorHandling: promhttp.ContinueOnError, 62 promhttp.HandlerOpts{
63 }) 63 ErrorLog: log.NewErrorLogger(),
64 ErrorHandling: promhttp.ContinueOnError,
65 }),
66 )
64 h.ServeHTTP(w, r) 67 h.ServeHTTP(w, r)
65} 68}
66 69
@@ -88,8 +91,7 @@ func main() {
88 log.Infof(" - %s", n) 91 log.Infof(" - %s", n)
89 } 92 }
90 93
91 // TODO(ts): Remove deprecated and problematic InstrumentHandlerFunc usage. 94 http.HandleFunc(*metricsPath, handler)
92 http.HandleFunc(*metricsPath, prometheus.InstrumentHandlerFunc("prometheus", handler))
93 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 95 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
94 w.Write([]byte(`<html> 96 w.Write([]byte(`<html>
95 <head><title>Node Exporter</title></head> 97 <head><title>Node Exporter</title></head>