adds metric middlware to route register

This commit is contained in:
bergquist
2017-09-13 15:18:52 +02:00
committed by Carl Bergquist
parent 6372e22180
commit 4bc6ecb241
5 changed files with 10 additions and 21 deletions

View File

@@ -3,6 +3,7 @@ package api
import (
"net/http"
"github.com/grafana/grafana/pkg/middleware"
macaron "gopkg.in/macaron.v1"
)
@@ -68,13 +69,15 @@ func (rr *routeRegister) Register(router Router) *macaron.Router {
}
func (rr *routeRegister) route(pattern, method string, handlers ...macaron.Handler) {
//inject metrics
//inject tracing
h := append(rr.subfixHandlers, handlers...)
h = append([]macaron.Handler{middleware.RequestMetrics(pattern)}, h...)
rr.routes = append(rr.routes, route{
method: method,
pattern: rr.prefix + pattern,
handlers: append(rr.subfixHandlers, handlers...),
handlers: h,
})
}