Fix use multi process for load metrics#429
Fix use multi process for load metrics#429saeedAdelpour wants to merge 4 commits intodjango-commons:masterfrom
Conversation
|
TBH, I don't think this PR is a good idea. the function you modified is (IMHO, since I didn't originally write this code) is more of a reference code. swallowing exception in this way, is really bad idea. |
|
Hi, Thank you for your response. I agree with handling the exception this way, so I removed the However, I'm sure this code: prometheus_client.start_http_server(port, addr=addr)won't work with registry = prometheus_client.CollectorRegistry()to prometheus_client.start_http_server(port, addr=addr, registry=registry)When we set Here are the steps to reproduce the bug:
Thank you for your attention. Please tell me if I am wrong about anything. |
|
Hi, I hope you’re doing well. I added a pull request 3 weeks ago. Could you spare some moment to review it? I’d really appreciate it. |
Hi,
I opened a pull request (#407) that was closed. I think I need to explain the problem in more detail.
The first problem is with using the
PROMETHEUS_METRICS_EXPORT_PORTandPROMETHEUS_METRICS_EXPORT_ADDRESSenvironment variables. Here is the command that starts my app:The first error we encounter is
Address already in usebecause inexports.py, line 45, the functionprometheus_client.start_http_server(port, addr=addr)is called without checking if the port is already in use. This should be handled with atry-exceptblock.The second problem is when we use the
PROMETHEUS_MULTIPROC_DIRenvironment variable. The functionSetupPrometheusEndpointOnPortdoes not checkPROMETHEUS_MULTIPROC_DIRand only runs this:The implementation of this part must be similar to
ExportToDjangoView. I mistakenly forced the app to usePROMETHEUS_MULTIPROC_DIR, but I have fixed it.Thank you for your attention. Please tell me where I am wrong about it.