starlette_request_duration_seconds_bucket le bug
bendyna-vitalii opened this issue · comments
bendyna-vitalii commented
Seems that there is a bug in starlette-exporter
Here is a peace of my code:
app = fastapi.FastAPI(docs_url="/swagger", redoc_url="/swagger2")
app.add_middleware(PrometheusMiddleware,app_name="listener", skip_paths=["/metrics"])
app.add_route("/metrics", handle_metrics)
.....
server_config = uvicorn.Config(
app=app,
host=props["webserver.host"],
port=int(props["webserver.port"]),
loop="asyncio"
)
server = uvicorn.Server(server_config)
await server.serve()
This works, metrics are exposed in /metrics
path, but after each request to any endpoint all these metrics are increased by +1:
starlette_request_duration_seconds_bucket{app_name="listener",le="0.01",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="0.025",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="0.05",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="0.075",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="0.1",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="0.25",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="0.5",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="0.75",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="1.0",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="2.5",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="5.0",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="7.5",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="10.0",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
starlette_request_duration_seconds_bucket{app_name="listener",le="+Inf",method="DELETE",path="/remove_all_connections",status_code="401"} 1.0
I believe that for each request only one metric should be increased. Maybe I'm doing something wrong....
FastAPI version: 0.110.0
starlette-exporter: v0.21.0)
I'm using routers in FastAPI: app.include_router(private_router.router)
bendyna-vitalii commented
Nope, it's normal behaviour. Sorry.