forked from CGM_Public/pretix_original
Fix bugs in metrics tooling
This commit is contained in:
@@ -43,7 +43,7 @@ class Metric(object):
|
|||||||
else:
|
else:
|
||||||
named_labels = []
|
named_labels = []
|
||||||
for labelname in self.labelnames:
|
for labelname in self.labelnames:
|
||||||
named_labels.append('{}="{}",'.format(labelname, labels[labelname]))
|
named_labels.append('{}="{}"'.format(labelname, labels[labelname]))
|
||||||
|
|
||||||
return metricname + "{" + ",".join(named_labels) + "}"
|
return metricname + "{" + ",".join(named_labels) + "}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import base64
|
||||||
import hmac
|
import hmac
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -26,7 +27,7 @@ def serve_metrics(request):
|
|||||||
if method.lower() != "basic":
|
if method.lower() != "basic":
|
||||||
return unauthed_response()
|
return unauthed_response()
|
||||||
|
|
||||||
user, passphrase = credentials.strip().decode("base64").split(":", 1)
|
user, passphrase = base64.b64decode(credentials.strip()).decode().split(":", 1)
|
||||||
|
|
||||||
if not hmac.compare_digest(user, settings.METRICS_USER):
|
if not hmac.compare_digest(user, settings.METRICS_USER):
|
||||||
return unauthed_response()
|
return unauthed_response()
|
||||||
@@ -37,7 +38,7 @@ def serve_metrics(request):
|
|||||||
m = metrics.metric_values()
|
m = metrics.metric_values()
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
for metric, value in m:
|
for metric, value in m.items():
|
||||||
output.append("{} {}".format(metric, str(value)))
|
output.append("{} {}".format(metric, str(value)))
|
||||||
|
|
||||||
content = "\n".join(output)
|
content = "\n".join(output)
|
||||||
|
|||||||
Reference in New Issue
Block a user