Skip to content

Commit

Permalink
Merge pull request #4319 from alphagov/ris-eventlet-stats
Browse files Browse the repository at this point in the history
add handling of `NOTIFY_EVENTLET_STATS`
  • Loading branch information
risicle authored Jan 10, 2025
2 parents cbfa560 + d9b616a commit 6d6bf80
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was automatically copied from notifications-utils@92.0.2
# This file was automatically copied from notifications-utils@93.0.0

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
5 changes: 3 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
from flask_sqlalchemy import SQLAlchemy
from gds_metrics import GDSMetrics
from gds_metrics.metrics import Gauge, Histogram
from notifications_utils import logging, request_helper
from notifications_utils import request_helper
from notifications_utils.celery import NotifyCelery
from notifications_utils.clients.redis.redis_client import RedisClient
from notifications_utils.clients.signing.signing_client import Signing
from notifications_utils.clients.statsd.statsd_client import StatsdClient
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
from notifications_utils.eventlet import EventletTimeout
from notifications_utils.local_vars import LazyLocalGetter
from notifications_utils.logging import flask as utils_logging
from sqlalchemy import event
from werkzeug.exceptions import HTTPException as WerkzeugHTTPException
from werkzeug.local import LocalProxy
Expand Down Expand Up @@ -176,7 +177,7 @@ def create_app(application):
migrate.init_app(application, db=db)
ma.init_app(application)
statsd_client.init_app(application)
logging.init_app(application, statsd_client)
utils_logging.init_app(application, statsd_client)

notify_celery.init_app(application)
signing.init_app(application)
Expand Down
2 changes: 2 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class Config:
# Antivirus
ANTIVIRUS_ENABLED = True

NOTIFY_EVENTLET_STATS = os.getenv("NOTIFY_EVENTLET_STATS", "0") == "1"

###########################
# Default config values ###
###########################
Expand Down
11 changes: 8 additions & 3 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
from app import create_app # noqa
from app.notify_api_flask_app import NotifyApiFlaskApp # noqa

from notifications_utils.eventlet import EventletTimeoutMiddleware, using_eventlet # noqa
import notifications_utils.eventlet as utils_eventlet # noqa

application = NotifyApiFlaskApp("app")

create_app(application)

if using_eventlet:
application.wsgi_app = EventletTimeoutMiddleware(
if utils_eventlet.using_eventlet:
application.wsgi_app = utils_eventlet.EventletTimeoutMiddleware(
application.wsgi_app,
timeout_seconds=int(os.getenv("HTTP_SERVE_TIMEOUT_SECONDS", 30)),
)

if application.config["NOTIFY_EVENTLET_STATS"]:
import greenlet

greenlet.settrace(utils_eventlet.account_greenlet_times)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was automatically copied from notifications-utils@92.0.2
# This file was automatically copied from notifications-utils@93.0.0

[tool.black]
line-length = 120
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SQLAlchemy==1.4.41
notifications-python-client==8.0.1

# Run `make bump-utils` to update to the latest version
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@92.0.2
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@93.0.0

# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
prometheus-client==0.14.1
Expand Down
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ gds-metrics @ git+https://github.com/alphagov/gds_metrics_python.git@6f1840a57b6
govuk-bank-holidays==0.15
# via notifications-utils
greenlet==3.0.3
# via eventlet
# via
# eventlet
# sqlalchemy
gunicorn @ git+https://github.com/benoitc/gunicorn.git@1299ea9e967a61ae2edebe191082fd169b864c64
# via
# -r requirements.in
Expand All @@ -110,7 +112,7 @@ itsdangerous==2.2.0
# via
# flask
# notifications-utils
jinja2==3.1.4
jinja2==3.1.5
# via
# flask
# notifications-utils
Expand Down Expand Up @@ -143,7 +145,7 @@ mistune==0.8.4
# via notifications-utils
notifications-python-client==8.0.1
# via -r requirements.in
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@7793546055d819904c76da73628b64d3eda255c4
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@7322d3573eb54285166cae84da22edfae8067f02
# via -r requirements.in
ordered-set==4.1.0
# via notifications-utils
Expand Down
5 changes: 3 additions & 2 deletions requirements_for_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ greenlet==3.0.3
# via
# -r requirements.txt
# eventlet
# sqlalchemy
gunicorn @ git+https://github.com/benoitc/gunicorn.git@1299ea9e967a61ae2edebe191082fd169b864c64
# via
# -r requirements.txt
Expand All @@ -173,7 +174,7 @@ itsdangerous==2.2.0
# -r requirements.txt
# flask
# notifications-utils
jinja2==3.1.4
jinja2==3.1.5
# via
# -r requirements.txt
# flask
Expand Down Expand Up @@ -219,7 +220,7 @@ mypy-extensions==1.0.0
# via black
notifications-python-client==8.0.1
# via -r requirements.txt
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@7793546055d819904c76da73628b64d3eda255c4
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@7322d3573eb54285166cae84da22edfae8067f02
# via -r requirements.txt
ordered-set==4.1.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements_for_test_common.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was automatically copied from notifications-utils@92.0.2
# This file was automatically copied from notifications-utils@93.0.0

beautifulsoup4==4.12.3
pytest==8.3.4
Expand Down

0 comments on commit 6d6bf80

Please sign in to comment.