Skip to content

Commit

Permalink
Handle prometheus-client missing in webapp, too
Browse files Browse the repository at this point in the history
  • Loading branch information
matyasselmeci committed Mar 5, 2024
1 parent 7c00665 commit 34db322
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import flask
import flask.logging
from flask import Flask, Response, make_response, request, render_template, redirect, url_for, session
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from prometheus_client import make_wsgi_app
from io import StringIO
import logging
import os
Expand Down Expand Up @@ -1081,10 +1079,16 @@ def _get_authorized():
return default_authorized


# Enable prometheus integration with the topology webapp
app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {
'/metrics': make_wsgi_app()
})
try:
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from prometheus_client import make_wsgi_app
# Enable prometheus integration with the topology webapp
app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {
'/metrics': make_wsgi_app()
})
except ImportError:
print("*** /metrics endpoint unavailable: prometheus-client missing",
file=sys.stderr)


if __name__ == '__main__':
Expand Down

0 comments on commit 34db322

Please sign in to comment.