ExtractRouteName returns the route name associated with this request that was previously injected by the RouteInjector middleware or WithRouteName. This is the same route name used for trace and metric names, and is already suitable for use as a Prometheus label value.
(ctx context.Context)
| 41 | // This is the same route name used for trace and metric names, and is already suitable for use as a Prometheus label |
| 42 | // value. |
| 43 | func ExtractRouteName(ctx context.Context) string { |
| 44 | routeName, ok := ctx.Value(contextKeyRouteName).(string) |
| 45 | if !ok { |
| 46 | return "" |
| 47 | } |
| 48 | |
| 49 | return routeName |
| 50 | } |
| 51 | |
| 52 | func getRouteName(routeMatcher RouteMatcher, r *http.Request) string { |
| 53 | var routeMatch mux.RouteMatch |
no outgoing calls