Skip to content

Commit

Permalink
fix(exports): use MultiProcessCollector registry for prometheus http …
Browse files Browse the repository at this point in the history
…server
  • Loading branch information
saeedAdelpour committed May 27, 2023
1 parent 4337a1e commit e6493bc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion django_prometheus/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ def SetupPrometheusEndpointOnPort(port, addr=""):
"autoreloader is active. Use the URL exporter, or start django "
"with --noreload. See documentation/exports.md."
)

registry = prometheus_client.CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
try:
prometheus_client.start_http_server(port, addr=addr)
prometheus_client.start_http_server(port, addr=addr, registry=registry)
except OSError:
"""
first process serves metrics on port 8001, other processes raise error: port already in use
Expand Down

0 comments on commit e6493bc

Please sign in to comment.