8000 Fix import of openmetrics, and make accept handling more general. by brian-brazil · Pull Request #318 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

Fix import of openmetrics, and make accept handling more general. #318

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

Merged
merged 1 commit into from
Oct 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions prometheus_client/exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from wsgiref.simple_server import make_server, WSGIRequestHandler

from prometheus_client import core
from prometheus_client import openmetrics
from prometheus_client.openmetrics import exposition as openmetrics
try:
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from SocketServer import ThreadingMixIn
Expand Down Expand Up @@ -124,9 +124,9 @@ def sample_line(s):
def choose_encoder(accept_header):
accept_header = accept_header or ''
for accepted in accept_header.split(','):
if accepted == 'application/openmetrics-text; version=0.0.1':
return (openmetrics.exposition.generate_latest,
openmetrics.exposition.CONTENT_TYPE_LATEST)
if accepted.split(';')[0].strip() == 'application/openmetrics-text':
return (openmetrics.generate_latest,
openmetrics.CONTENT_TYPE_LATEST)
return (generate_latest, CONTENT_TYPE_LATEST)


Expand Down
0