Skip to content

Commit 6bb522b

Browse files
juergenhoetzelmartinlindhe
authored andcommitted
Use the new prometheus http API (prometheus-community#71)
* Use the new prometheus http API The new recommended way of using the prometheus http handler is through the promhttp package: https://github.com/prometheus/client_golang/releases/tag/v0.8.0 (Separated HTTP exposition, allowing custom HTTP handlers (package promhttp)) * ListenAndServe always returns a non-nil error * updated vendored dependencies
1 parent 9d51525 commit 6bb522b

20 files changed

+1089
-219
lines changed

exporter.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/martinlindhe/wmi_exporter/collector"
1717
"github.com/prometheus/client_golang/prometheus"
18+
"github.com/prometheus/client_golang/prometheus/promhttp"
1819
"github.com/prometheus/common/log"
1920
"github.com/prometheus/common/version"
2021
)
@@ -177,7 +178,7 @@ func main() {
177178
nodeCollector := WmiCollector{collectors: collectors}
178179
prometheus.MustRegister(nodeCollector)
179180

180-
http.Handle(*metricsPath, prometheus.Handler())
181+
http.Handle(*metricsPath, promhttp.Handler())
181182
http.HandleFunc("/health", healthCheck)
182183
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
183184
http.Redirect(w, r, *metricsPath, http.StatusMovedPermanently)
@@ -188,9 +189,7 @@ func main() {
188189

189190
go func() {
190191
log.Infoln("Starting server on", *listenAddress)
191-
if err := http.ListenAndServe(*listenAddress, nil); err != nil {
192-
log.Fatalf("cannot start WMI exporter: %s", err)
193-
}
192+
log.Fatalf("cannot start WMI exporter: %s", http.ListenAndServe(*listenAddress, nil))
194193
}()
195194

196195
for {

vendor/github.com/prometheus/client_golang/prometheus/counter.go

+2-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/client_golang/prometheus/desc.go

+3-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/client_golang/prometheus/doc.go

+34-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/client_golang/prometheus/gauge.go

+9-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/client_golang/prometheus/go_collector.go

+28-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/prometheus/client_golang/prometheus/histogram.go

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)