Skip to content

Commit ae4801f

Browse files
authored
Merge pull request #105 from korfuri/cleanup
Upgrade to a recent prometheus client and fix tests
2 parents 7c7160d + 682ddf2 commit ae4801f

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

django_prometheus/middleware.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import django
22
from prometheus_client import Counter, Histogram
3-
from prometheus_client.utils import INF
43

54
from django_prometheus.utils import Time, TimeSince, PowersOf
65

@@ -49,7 +48,7 @@ def process_response(self, request, response):
4948
buckets=(.01, .025, .05, .075,
5049
.1, .25, .5, .75,
5150
1.0, 2.5, 5.0, 7.5,
52-
10.0, 25.0, 50.0, 75.0, INF))
51+
10.0, 25.0, 50.0, 75.0, float("inf")))
5352
requests_unknown_latency = Counter(
5453
'django_http_requests_unknown_latency_total',
5554
'Count of requests for which the latency was unknown.')

django_prometheus/testutils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def getMetricFromFrozenRegistry(self, metric_name, frozen_registry,
4646
"""Gets a single metric from a frozen registry."""
4747
for metric in frozen_registry:
4848
for sample in metric.samples:
49-
if sample.name == metric_name and sample.labels == labels:
50-
return sample.value
49+
if sample[0] == metric_name and sample[1] == labels:
50+
return sample[2]
5151

5252
def getMetric(self, metric_name, registry=REGISTRY, **labels):
5353
"""Gets a single metric."""
@@ -59,8 +59,8 @@ def getMetricVectorFromFrozenRegistry(self, metric_name, frozen_registry):
5959
output = []
6060
for metric in frozen_registry:
6161
for sample in metric.samples:
62-
if sample.name == metric_name:
63-
output.append((sample.labels, sample.value))
62+
if sample[0] == metric_name:
63+
output.append((sample[1], sample[2]))
6464
return output
6565

6666
def getMetricVector(self, metric_name, registry=REGISTRY):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Django>=1.8
22
django-redis>=4.8
33
pep8>=1.6.2
4-
prometheus-client>=0.0.21,<0.4.0
4+
prometheus-client>=0.7
55
pip-prometheus>=1.1.0
66
mock>=1.0.1
77
mysqlclient<1.4

0 commit comments

Comments
 (0)