Skip to content

Commit

Permalink
Merge pull request #26903 from dimagi/sk/only-debug
Browse files Browse the repository at this point in the history
only enable metrics view in DEBUG mode
  • Loading branch information
snopoke authored Mar 19, 2020
2 parents 5e86359 + 35d49e8 commit 33e2b24
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions corehq/util/metrics/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import os

from django.http import HttpResponse, HttpResponseNotFound

import prometheus_client
from django.http import HttpResponse
import settings
from prometheus_client import multiprocess


def prometheus_metrics(request):
"""Exports /metrics as a Django view.
"""Exports /metrics as a Django view. Only available in DEBUG mode.
"""
if not settings.DEBUG:
return HttpResponseNotFound()

if "prometheus_multiproc_dir" in os.environ:
registry = prometheus_client.CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
Expand Down

0 comments on commit 33e2b24

Please sign in to comment.