MCPcopy
hub / github.com/grafana/dskit / ExtractRouteName

Function ExtractRouteName

middleware/route_injector.go:43–50  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
43func ExtractRouteName(ctx context.Context) string {
44 routeName, ok := ctx.Value(contextKeyRouteName).(string)
45 if !ok {
46 return ""
47 }
48
49 return routeName
50}
51
52func getRouteName(routeMatcher RouteMatcher, r *http.Request) string {
53 var routeMatch mux.RouteMatch

Callers 5

TestRouteInjectorFunction · 0.85
getRouteNameMethod · 0.85
wrapWithOTelMethod · 0.85
httpOperationNameFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestRouteInjectorFunction · 0.68