update thrift, opencensus, others (#893)

* update thrift, opencensus, others

* stats: update to opencensus 0.6.0 view api
This commit is contained in:
Reed Allman
2018-03-26 15:43:49 -07:00
committed by GitHub
parent 0ce5c4500b
commit 8af605cf3d
1266 changed files with 122191 additions and 28775 deletions

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))
}
}