-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
When submounting routes, rather than the full path template being used, only the mount prefix is used.
Running the following app:
from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.responses import Response
from starlette.routing import Mount, Route
from starlette_prometheus import PrometheusMiddleware, metrics
async def foo(request):
return Response()
async def bar_baz(request):
return Response()
routes = [
Route("/foo", foo),
Mount("/bar", Route("/baz", bar_baz)),
Route("/metrics", metrics),
]
middleware = [Middleware(PrometheusMiddleware)]
app = Starlette(routes=routes, middleware=middleware)
Then making the following requests:
$ curl localhost:8000/foo
$ curl localhost:8000/bar/baz
$ curl localhost:8000/metrics
Gives the following output (I only included one metric as an example, but it's the same for all of them). Note the label for the request to localhost:8000/bar/baz has a path label of /bar.
starlette_requests_total{method="GET",path_template="/foo"} 1.0
starlette_requests_total{method="GET",path_template="/bar"} 1.0
starlette_requests_total{method="GET",path_template="/metrics"} 1.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels