Connexion 3.0 and Prometheus #1810
danielbprice
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi @danielbprice, Connexion sets We could either:
Not yet sure which is the best approach. We can find the Starlette router used by Connexion like this: for middleware in self.middleware_stack:
if isinstance(middleware, RoutingMiddleware):
router = middleware.router For any of the possible approaches mentioned above, this should be enough info to get it to work. We would appreciate it if you could try it out and report back. FYI, there's two Prometheus middleware that work with starlette: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been trying without much success to plug together aioprometheus==23.3.0 and connexion==3.0.1[swagger-ui,uvicorn]. The closest I can get is as follows:
What I find if I run this is that every request traces back. This is because the MetricsMiddleware is trying to inspect some attributes of what it thinks is a starlette, but is really a ConnexionMiddleware:
The failing routine inside of MetricsMiddleware looks like this (https://github.com/claws/aioprometheus/blob/master/src/aioprometheus/asgi/middleware.py#L213):
I found that subclassing MetricsMiddleware and setting self.use_template_urls = False does enable things to work, however then you lose coalescing of metrics by route.
I was wondering if anyone else has successfully built a Connexion + Prometheus setup. I am not wedded to aioprometheus.
If there is a good recipe out there, could the authors add it to the cookbook please? This could save a lot of pain and suffering.
Beta Was this translation helpful? Give feedback.
All reactions