8000 Simplify Flask documentation example · Issue #562 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

Simplify Flask documentation example #562

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

Closed
moniquelive opened this issue Jun 29, 2020 · 4 comments
Closed

Simplify Flask documentation example #562

moniquelive opened this issue Jun 29, 2020 · 4 comments

Comments

@moniquelive
Copy link
Contributor

The Flask example can be much simplified like this

from flask import Flask
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from prometheus_client import make_wsgi_app

# Create my app
app = Flask(__name__)

# Add prometheus wsgi middleware to route /metrics requests
app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {
    '/metrics': make_wsgi_app()
})

It simply instruments your app object, no need to change semantics.

@moniquelive moniquelive changed the title Simplify Flask example Simplify Flask documentation example Jun 29, 2020
@moniquelive
Copy link
Contributor Author

Use app.wsgi_app/app.wsgi_app instead of app_dispatch/app in case it wasn't clear.

@brian-brazil
Copy link
Contributor

I've never used Flask so I'll have to take your word for it. Would you like to send a PR?

@dgzlopes
Copy link

I think this can be closed! #563 was merged.

@moniquelive
Copy link
Contributor Author

Of course! 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

No branches or pull requests

3 participants
0