Skip to content

Commit

Permalink
Merge pull request #719 from EvanBldy/master
Browse files Browse the repository at this point in the history
prometheus
  • Loading branch information
EvanBldy authored Oct 10, 2023
2 parents 1a6039c + 57d662d commit 257951a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
35 changes: 21 additions & 14 deletions zou/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,31 @@ def add_permissions(_, payload):

def load_api():
from zou.app import api
from zou.app.utils import permissions
from zou import __version__ as zou_version

api.configure(app)
try:
from prometheus_flask_exporter.multiprocess import (
GunicornPrometheusMetrics,
)

metrics = GunicornPrometheusMetrics(
app, defaults_prefix="zou", group_by="url_rule"
)
except ValueError:
from prometheus_flask_exporter import RESTfulPrometheusMetrics

metrics = RESTfulPrometheusMetrics(
app, api, defaults_prefix="zou", group_by="url_rule"
)
metrics.info("zou_info", "Application info", version=zou_version)
if config.PROMETHEUS_METRICS_ENABLED:
try:
from prometheus_flask_exporter.multiprocess import (
GunicornPrometheusMetrics,
)

metrics = GunicornPrometheusMetrics(
app, defaults_prefix="zou", group_by="url_rule"
)
except ValueError:
from prometheus_flask_exporter import RESTfulPrometheusMetrics

metrics = RESTfulPrometheusMetrics(
app,
api,
defaults_prefix="zou",
group_by="url_rule",
metrics_decorator=permissions.require_admin,
)
metrics.info("zou_info", "Application info", version=zou_version)

fs.mkdir_p(app.config["TMP_DIR"])
configure_auth()
Expand Down
2 changes: 2 additions & 0 deletions zou/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
SENTRY_SR = float(os.getenv("SENTRY_SR", 1.0))
SENTRY_DEBUG_URL = os.getenv("SENTRY_DEBUG_URL", False)

PROMETHEUS_METRICS_ENABLED = envtobool("PROMETHEUS_METRICS_ENABLED", False)

CRISP_TOKEN = os.getenv("CRISP_TOKEN", "")

DEFAULT_TIMEZONE = os.getenv("DEFAULT_TIMEZONE", "Europe/Paris")
Expand Down

0 comments on commit 257951a

Please sign in to comment.