Skip to content

Commit

Permalink
Use the new prometheus http API (#71)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
juergenhoetzel authored and martinlindhe committed Apr 30, 2017
1 parent 9d51525 commit 6bb522b
Show file tree
Hide file tree
Showing 20 changed files with 1,089 additions and 219 deletions.
7 changes: 3 additions & 4 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/martinlindhe/wmi_exporter/collector"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"
)
Expand Down Expand Up @@ -177,7 +178,7 @@ func main() {
nodeCollector := WmiCollector{collectors: collectors}
prometheus.MustRegister(nodeCollector)

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

go func() {
log.Infoln("Starting server on", *listenAddress)
if err := http.ListenAndServe(*listenAddress, nil); err != nil {
log.Fatalf("cannot start WMI exporter: %s", err)
}
log.Fatalf("cannot start WMI exporter: %s", http.ListenAndServe(*listenAddress, nil))
}()

for {
Expand Down
12 changes: 2 additions & 10 deletions vendor/github.com/prometheus/client_golang/prometheus/counter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions vendor/github.com/prometheus/client_golang/prometheus/desc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 34 additions & 30 deletions vendor/github.com/prometheus/client_golang/prometheus/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions vendor/github.com/prometheus/client_golang/prometheus/gauge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions vendor/github.com/prometheus/client_golang/prometheus/histogram.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6bb522b

Please sign in to comment.