starlette_exporter
starlette_exporter copied to clipboard
Cannot use `await request.body()` in label
I would like to have labels applied which will be populated from the content of the request body.
tried something like:
async def get_label_value(request:Request):
return request.json().get("label", None)
app.add_middleware(
PrometheusMiddleware,
labels={"custom_label": get_label_value}
)
app.add_route("/metrics", handle_metrics)
But upon a request the call hangs.
I know this is a known issue with starlette_exporter https://github.com/encode/starlette/issues/847
BUT if there is a way for me to include labels based on some values in the request body I would love to know!