Skip to content
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

add handling of NOTIFY_EVENTLET_STATS #4319

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 3 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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)
2 changes: 2 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
@@ -132,6 +132,8 @@ class Config:
# Antivirus
ANTIVIRUS_ENABLED = True

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

###########################
# Default config values ###
###########################
11 changes: 8 additions & 3 deletions application.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -23,7 +23,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
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -95,7 +95,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
@@ -112,7 +114,7 @@ itsdangerous==2.2.0
# via
# flask
# notifications-utils
jinja2==3.1.4
jinja2==3.1.5
# via
# flask
# notifications-utils
@@ -145,7 +147,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
5 changes: 3 additions & 2 deletions requirements_for_test.txt
Original file line number Diff line number Diff line change
@@ -155,6 +155,7 @@ greenlet==3.0.3
# via
# -r requirements.txt
# eventlet
# sqlalchemy
gunicorn @ git+https://github.com/benoitc/gunicorn.git@1299ea9e967a61ae2edebe191082fd169b864c64
# via
# -r requirements.txt
@@ -175,7 +176,7 @@ itsdangerous==2.2.0
# -r requirements.txt
# flask
# notifications-utils
jinja2==3.1.4
jinja2==3.1.5
# via
# -r requirements.txt
# flask
@@ -221,7 +222,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
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