Allow a nil RouteMatcher in instrumentation (#1852)

So the instrumentation can be used for things other than gorilla.
This commit is contained in:
Tom Wilkie
2016-09-05 15:49:20 +01:00
committed by GitHub
parent b0a630590c
commit 39be421141

View File

@@ -51,7 +51,7 @@ func (i Instrument) Wrap(next http.Handler) http.Handler {
// prometheus.
func (i Instrument) getRouteName(r *http.Request) string {
var routeMatch mux.RouteMatch
if i.RouteMatcher.Match(r, &routeMatch) {
if i.RouteMatcher != nil && i.RouteMatcher.Match(r, &routeMatch) {
if name := routeMatch.Route.GetName(); name != "" {
return name
}