trallnag / prometheus-fastapi-instrumentator

Instrument your FastAPI with Prometheus metrics.
ISC License
929 stars 83 forks source link

Inprogress metrics ignore namespace and subsystem #285

Open jhuitema opened 6 months ago

jhuitema commented 6 months ago

When I try to use the inprogress metrics, the metric_namespace and metric_subsystem settings are ignored.

Reproduction example

_APP = FastAPI(
    title="MyApp",
    version=__version__,
)
_PROM_INST = Instrumentator(
    should_instrument_requests_inprogress=True,
    inprogress_labels=True,
)
_PROM_INST.instrument(_APP, metric_namespace="myapp", metric_subsystem="webapi")
_PROM_INST.expose(_APP)

Result

This creates a http_requests_inprogress metric instead of the myapp_webapi_http_requests_inprogress metric I would expect.

Workaround

I can get around this by setting my own inprogress_name to include the namespace and subsystem but it would be more convenient if it was done for me.

Potential Fix

I think this could be fixed by adding the metric_namespace and metric_subsystem to this line.