Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is working outside of request context possible #171

Open
gautierrog opened this issue Feb 20, 2024 · 1 comment
Open

Is working outside of request context possible #171

gautierrog opened this issue Feb 20, 2024 · 1 comment

Comments

@gautierrog
Copy link

Hello,

I try to use the lib within a celery worker. I used a multiprocess metric and called metrics.start_http_server but the metrics I setup are never updated.

How does this lib work outside of flask http requests?

@rycus86
Copy link
Owner

rycus86 commented Feb 20, 2024

Hey,

This library is intended to use with Flask as it provides convenient wrappers for its HTTP handler functions. Underneath, it uses https://github.com/prometheus/client_python and all metrics exposed through that to the same registry will also show up on the metrics endpoint.
Depending on your use-case, perhaps you'd just need the underlying library only and use its exposition options to expose them to your scraper?
If not, perhaps a minimal example would help figuring out what options you have.

How does this lib work outside of flask http requests?

To answer this more directly, using metrics (counters, summary, etc.) from the underlying Prometheus library will all show up together with the Flask specific metrics, as long as they all use the same Prometheus registry. (there's a default one unless overridden)

Hope this helps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants