better handling of openmetrics mtype

master
parent 6f8ddd4cb8
commit 0ff3c1ca56
  1. 3
      DNSLG/Formatter.py
  2. 6
      DNSLG/__init__.py

@ -415,7 +415,8 @@ class JsonFormatter(Formatter):
from prometheus_client.core import InfoMetricFamily, GaugeMetricFamily
from prometheus_client import CollectorRegistry, generate_latest
from prometheus_client import CollectorRegistry
from prometheus_client.openmetrics.exposition import generate_latest
class OpenMetricsFormatter(Formatter):
class DnsLgCollector(object):

@ -131,7 +131,7 @@ Disallow: /
if not format:
mformat = req.accept.best_match(['text/html', 'application/xml',
'application/json', 'text/dns',
'text/plain', 'application/openmetrics-text'])
'text/plain', 'application/openmetrics-text;version=0.0.1'])
if mformat == "text/html":
format = "HTML"
elif mformat == "application/xml":
@ -142,7 +142,7 @@ Disallow: /
format = "ZONE"
elif mformat == "text/plain":
format = "TEXT"
elif mformat == 'application/openmetrics-text':
elif mformat == 'application/openmetrics-text;version=0.0.1':
format = 'OPENMETRICS'
if not mformat:
output = "No suitable output format found\n"
@ -163,7 +163,7 @@ Disallow: /
elif format == "XML":
mtype = 'application/xml'
elif format == 'OPENMETRICS':
mtype = 'text/plain; charset=%s' % self.encoding
mtype = 'application/openmetrics-text; version=0.0.1; charset=%s' % self.encoding
else:
output = "Unsupported format \"%s\"\n" % format
send_response(start_response, '400 Bad request', output, plaintype)

Loading…
Cancel
Save