prometheus / client_python

Prometheus instrumentation library for Python applications
Apache License 2.0
3.96k stars 798 forks source link

prometheus_client.generate_latest() #986

Open GeluConstantin opened 10 months ago

GeluConstantin commented 10 months ago

Hi,

I use this method in combination with fastAPI in order to expose metrics over the API. The data come from a JSON file saved on Linux system (where the service runs).

When changing the values in the file in order to create metrics the metric value does not change, only when restarting the web server (Uvicorn).

Why are the changed values not recalculated?

For opening the file I use the standard command with open('filename.json', mode = 'r') as f:

Thank you in advance for the feedback!

csmarchbanks commented 9 months ago

Would you be able to provide more details? If you are not re-reading (and possibly re-opening) the file on each request I can imagine the file in the Python process not being updated.