update common package (#4015)

This commit is contained in:
Krasi Georgiev 2018-03-27 07:51:56 +03:00 committed by Goutham Veeramachaneni
parent 5fec98d0a7
commit dfd6709a44
4 changed files with 27 additions and 23 deletions

View file

@ -26,7 +26,7 @@ const (
// The Content-Type values for the different wire protocols.
FmtUnknown Format = `<unknown>`
FmtText Format = `text/plain; version=` + TextVersion
FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8`
FmtProtoDelim Format = ProtoFmt + ` encoding=delimited`
FmtProtoText Format = ProtoFmt + ` encoding=text`
FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text`

View file

@ -214,6 +214,9 @@ func (d Duration) String() string {
ms = int64(time.Duration(d) / time.Millisecond)
unit = "ms"
)
if ms == 0 {
return "0s"
}
factors := map[string]int64{
"y": 1000 * 60 * 60 * 24 * 365,
"w": 1000 * 60 * 60 * 24 * 7,

View file

@ -46,6 +46,10 @@ func (r *Router) WithPrefix(prefix string) *Router {
// handle turns a HandlerFunc into an httprouter.Handle.
func (r *Router) handle(handlerName string, h http.HandlerFunc) httprouter.Handle {
if r.instrh != nil {
// This needs to be outside the closure to avoid data race when reading and writing to 'h'.
h = r.instrh(handlerName, h)
}
return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@ -53,9 +57,6 @@ func (r *Router) handle(handlerName string, h http.HandlerFunc) httprouter.Handl
for _, p := range params {
ctx = context.WithValue(ctx, param(p.Key), p.Value)
}
if r.instrh != nil {
h = r.instrh(handlerName, h)
}
h(w, req.WithContext(ctx))
}
}

38
vendor/vendor.json vendored
View file

@ -762,50 +762,50 @@
{
"checksumSHA1": "i+0TxE6bOpJdPNOeNHpO0vMzFh4=",
"path": "github.com/prometheus/common/config",
"revision": "89604d197083d4781071d3c65855d24ecfb0a563",
"revisionTime": "2018-01-10T21:49:58Z"
"revision": "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a",
"revisionTime": "2018-03-26T16:04:09Z"
},
{
"checksumSHA1": "xfnn0THnqNwjwimeTClsxahYrIo=",
"checksumSHA1": "+wZ+Pa6NX+NOxUvayXBXGOcqFe8=",
"path": "github.com/prometheus/common/expfmt",
"revision": "e3fb1a1acd7605367a2b378bc2e2f893c05174b7",
"revisionTime": "2017-11-04T09:59:07Z"
"revision": "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a",
"revisionTime": "2018-03-26T16:04:09Z"
},
{
"checksumSHA1": "GWlM3d2vPYyNATtTFgftS10/A9w=",
"path": "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg",
"revision": "e3fb1a1acd7605367a2b378bc2e2f893c05174b7",
"revisionTime": "2017-11-04T09:59:07Z"
"revision": "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a",
"revisionTime": "2018-03-26T16:04:09Z"
},
{
"checksumSHA1": "3VoqH7TFfzA6Ds0zFzIbKCUvBmw=",
"checksumSHA1": "YU+/K48IMawQnToO4ETE6a+hhj4=",
"path": "github.com/prometheus/common/model",
"revision": "e3fb1a1acd7605367a2b378bc2e2f893c05174b7",
"revisionTime": "2017-11-04T09:59:07Z"
"revision": "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a",
"revisionTime": "2018-03-26T16:04:09Z"
},
{
"checksumSHA1": "Yseprf8kAFr/s7wztkQnrFuFN+8=",
"path": "github.com/prometheus/common/promlog",
"revision": "e3fb1a1acd7605367a2b378bc2e2f893c05174b7",
"revisionTime": "2017-11-04T09:59:07Z"
"revision": "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a",
"revisionTime": "2018-03-26T16:04:09Z"
},
{
"checksumSHA1": "1H28FCxsaAIm6kvue+Wfdd8Lq6M=",
"path": "github.com/prometheus/common/promlog/flag",
"revision": "e3fb1a1acd7605367a2b378bc2e2f893c05174b7",
"revisionTime": "2017-11-04T09:59:07Z"
"revision": "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a",
"revisionTime": "2018-03-26T16:04:09Z"
},
{
"checksumSHA1": "h6H+CjfOU6FfHV8cLWHN1VhAqp8=",
"checksumSHA1": "9doPk0x0LONG/idxK61JnZYcxBs=",
"path": "github.com/prometheus/common/route",
"revision": "e4aa40a9169a88835b849a6efb71e05dc04b88f0",
"revisionTime": "2018-03-12T11:28:59Z"
"revision": "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a",
"revisionTime": "2018-03-26T16:04:09Z"
},
{
"checksumSHA1": "91KYK0SpvkaMJJA2+BcxbVnyRO0=",
"path": "github.com/prometheus/common/version",
"revision": "e3fb1a1acd7605367a2b378bc2e2f893c05174b7",
"revisionTime": "2017-11-04T09:59:07Z"
"revision": "38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a",
"revisionTime": "2018-03-26T16:04:09Z"
},
{
"checksumSHA1": "W218eJZPXJG783fUr/z6IaAZyes=",