use prometheus common logging

This commit is contained in:
Daniel Czerwonk 2017-05-28 01:12:01 +02:00
parent f6559b1715
commit 18fe778237
2 changed files with 41 additions and 4 deletions

View File

@ -3,12 +3,12 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"log"
"net/http" "net/http"
"os" "os"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
) )
const version string = "0.7.0" const version string = "0.7.0"
@ -61,7 +61,7 @@ func errorHandler(f func(http.ResponseWriter, *http.Request) error) http.Handler
err := f(w, r) err := f(w, r)
if err != nil { if err != nil {
log.Println(err) log.Errorln(err)
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
} }
} }
@ -78,8 +78,9 @@ func handleMetricsRequest(w http.ResponseWriter, r *http.Request) error {
c := NewMetricCollectorForProtocols(protocols) c := NewMetricCollectorForProtocols(protocols)
reg.MustRegister(c) reg.MustRegister(c)
h := promhttp.HandlerFor(reg, promhttp.HandlerOpts{}) promhttp.HandlerFor(reg, promhttp.HandlerOpts{
h.ServeHTTP(w, r) ErrorLog: log.NewErrorLogger(),
ErrorHandling: promhttp.ContinueOnError}).ServeHTTP(w, r)
} }
return nil return nil

36
vendor/vendor.json vendored
View File

@ -2,6 +2,12 @@
"comment": "", "comment": "",
"ignore": "test", "ignore": "test",
"package": [ "package": [
{
"checksumSHA1": "DYv6Q1+VfnUVxMwvk5IshAClLvw=",
"path": "github.com/Sirupsen/logrus",
"revision": "5e5dc898656f695e2a086b8e12559febbfc01562",
"revisionTime": "2017-05-15T10:45:16Z"
},
{ {
"checksumSHA1": "spyv5/YFBjYyZLZa1U2LBfDR8PM=", "checksumSHA1": "spyv5/YFBjYyZLZa1U2LBfDR8PM=",
"path": "github.com/beorn7/perks/quantile", "path": "github.com/beorn7/perks/quantile",
@ -56,6 +62,12 @@
"revision": "13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207", "revision": "13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207",
"revisionTime": "2017-04-27T09:54:55Z" "revisionTime": "2017-04-27T09:54:55Z"
}, },
{
"checksumSHA1": "vfkLfDs6hXtxdJNGdWQglsxFu40=",
"path": "github.com/prometheus/common/log",
"revision": "13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207",
"revisionTime": "2017-04-27T09:54:55Z"
},
{ {
"checksumSHA1": "0LL9u9tfv1KPBjNEiMDP6q7lpog=", "checksumSHA1": "0LL9u9tfv1KPBjNEiMDP6q7lpog=",
"path": "github.com/prometheus/common/model", "path": "github.com/prometheus/common/model",
@ -73,6 +85,30 @@
"path": "github.com/prometheus/procfs/xfs", "path": "github.com/prometheus/procfs/xfs",
"revision": "65c1f6f8f0fc1e2185eb9863a3bc751496404259", "revision": "65c1f6f8f0fc1e2185eb9863a3bc751496404259",
"revisionTime": "2017-05-19T19:08:37Z" "revisionTime": "2017-05-19T19:08:37Z"
},
{
"checksumSHA1": "J+ZM49hifaNMFSbPAEibmNoCMh8=",
"path": "golang.org/x/sys/unix",
"revision": "a55a76086885b80f79961eacb876ebd8caf3868d",
"revisionTime": "2017-05-24T02:50:34Z"
},
{
"checksumSHA1": "2Coyr3Bq1dPkFg+ZYHEq1+/Rn58=",
"path": "golang.org/x/sys/windows",
"revision": "a55a76086885b80f79961eacb876ebd8caf3868d",
"revisionTime": "2017-05-24T02:50:34Z"
},
{
"checksumSHA1": "ZdFZFaXmCgEEaEhVPkyXrnhKhsg=",
"path": "golang.org/x/sys/windows/registry",
"revision": "a55a76086885b80f79961eacb876ebd8caf3868d",
"revisionTime": "2017-05-24T02:50:34Z"
},
{
"checksumSHA1": "uVlUSSKplihZG7N+QJ6fzDZ4Kh8=",
"path": "golang.org/x/sys/windows/svc/eventlog",
"revision": "a55a76086885b80f79961eacb876ebd8caf3868d",
"revisionTime": "2017-05-24T02:50:34Z"
} }
], ],
"rootPath": "github.com/czerwonk/bird_exporter" "rootPath": "github.com/czerwonk/bird_exporter"