Skip to content

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

Merged
merged 1 commit into from
Apr 26, 2016
Merged

Add WSGI helper methods #78

merged 1 commit into from
Apr 26, 2016

Conversation

rmohr
Copy link
Contributor

@rmohr rmohr commented Apr 26, 2016

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?

@@ -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")
Copy link
Contributor

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.

Copy link
Contributor Author

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

@rmohr rmohr force-pushed the master branch 2 times, most recently from b2e4c33 to ab436cc Compare April 26, 2016 13:41
@@ -6,6 +6,7 @@
import socket
import time
import threading
from wsgiref.simple_server import make_server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sorts after contextlib

@brian-brazil
Copy link
Contributor

Could you add a short example to the README?

@rmohr rmohr force-pushed the master branch 2 times, most recently from af15138 to b532313 Compare April 26, 2016 14:09
@rmohr
Copy link
Contributor Author

rmohr commented Apr 26, 2016

Added an example to the README


```python
from prometheus_client import start_wsgi_server
import time
Copy link
Contributor

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

Copy link
Contributor Author

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.
@brian-brazil brian-brazil merged commit 9a188ac into prometheus:master Apr 26, 2016
@brian-brazil
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants