-
Notifications
You must be signed in to change notification settings - Fork 816
Add WSGI helper methods #78
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
Conversation
@@ -23,10 +24,37 @@ | |||
from urllib.parse import quote_plus | |||
|
|||
|
|||
CONTENT_TYPE_LATEST = 'text/plain; version=0.0.4; charset=utf-8' | |||
CONTENT_TYPE_LATEST = str("text/plain; version=0.0.4; charset=utf-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the str?
We're using single quotes in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the str?
Because of the future import for unicode_literals, WSGI needs a str object. It does not make any difference for the BasicHTTPServer.
We're using single quotes in this file.
Done
b2e4c33
to
ab436cc
Compare
@@ -6,6 +6,7 @@ | |||
import socket | |||
import time | |||
import threading | |||
from wsgiref.simple_server import make_server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sorts after contextlib
Could you add a short example to the README? |
af15138
to
b532313
Compare
Added an example to the README |
|
||
```python | ||
from prometheus_client import start_wsgi_server | ||
import time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not using this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Add helper methods to make it easy to start a prometheus server as WSGI app. This makes it easier to integrate with other WSGI applications like flask or to start exposing metrics in your WSGI server of choice.
Thanks! |
Hi,
I tried to integrate the library with flask. It's easy but I had to go through the source code to find out what to do.
With this helper classes I hope to make it even easier for others. Someone can then just create a flask WSGI app and a Prometheus WSGI app and can do the routing in a third app.
Maybe another helper method for that might be nice too?