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

Expose the used registry so custom collectors can be used #271

Open
wolph opened this issue Apr 14, 2021 · 0 comments
Open

Expose the used registry so custom collectors can be used #271

wolph opened this issue Apr 14, 2021 · 0 comments

Comments

@wolph
Copy link

wolph commented Apr 14, 2021

When trying to use a custom collector (https://github.com/prometheus/client_python#custom-collectors) the results don't show up when the prometheus_multiproc_dir is set. The problem is that the registry as defined at line 120 here is not accessible to register the collectors:

def ExportToDjangoView(request):
"""Exports /metrics as a Django view.
You can use django_prometheus.urls to map /metrics to this view.
"""
if "prometheus_multiproc_dir" in os.environ:
registry = prometheus_client.CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
else:
registry = prometheus_client.REGISTRY
metrics_page = prometheus_client.generate_latest(registry)
return HttpResponse(
metrics_page, content_type=prometheus_client.CONTENT_TYPE_LATEST
)

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

1 participant