claws / aioprometheus

A Prometheus Python client library for asyncio-based applications
175 stars 21 forks source link

Middleware attempts to create conflicting Counters if not added last #72

Closed JacobHenner closed 2 years ago

JacobHenner commented 2 years ago

In Starlette, every middleware class that has been added to an application is called each time an additional middleware class is added.

Unless aioprometheus's MetricsMiddleware is added as the last piece of middleware, it's __init__(...) will be called more than once. This causes an Exception when the Counter metrics are redefined with the same name in the same registry.

claws commented 2 years ago

Hmm, yeah looks that way. I'll look into developing a solution to this problem.

claws commented 2 years ago

Thanks for reporting issue. Hopefully fixed in latest 22.3.0 release.