mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 15:56:45 -04:00
Merge pull request #3399 from alphagov/timeout-stats-180344294
Add new metrics for slow / unknown delivery
This commit is contained in:
@@ -8,7 +8,7 @@ from notifications_utils.clients.zendesk.zendesk_client import (
|
|||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.exc import SQLAlchemyError
|
from sqlalchemy.exc import SQLAlchemyError
|
||||||
|
|
||||||
from app import notify_celery, zendesk_client
|
from app import notify_celery, statsd_client, zendesk_client
|
||||||
from app.aws import s3
|
from app.aws import s3
|
||||||
from app.config import QueueNames
|
from app.config import QueueNames
|
||||||
from app.cronitor import cronitor
|
from app.cronitor import cronitor
|
||||||
@@ -123,6 +123,7 @@ def timeout_notifications():
|
|||||||
notifications = dao_timeout_notifications(cutoff_time)
|
notifications = dao_timeout_notifications(cutoff_time)
|
||||||
|
|
||||||
for notification in notifications:
|
for notification in notifications:
|
||||||
|
statsd_client.incr(f'timeout-sending.{notification.sent_by}')
|
||||||
check_and_queue_callback_task(notification)
|
check_and_queue_callback_task(notification)
|
||||||
|
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from sqlalchemy.sql import functions
|
|||||||
from sqlalchemy.sql.expression import case
|
from sqlalchemy.sql.expression import case
|
||||||
from werkzeug.datastructures import MultiDict
|
from werkzeug.datastructures import MultiDict
|
||||||
|
|
||||||
from app import create_uuid, db
|
from app import create_uuid, db, statsd_client
|
||||||
from app.clients.sms.firetext import (
|
from app.clients.sms.firetext import (
|
||||||
get_message_status_and_reason_from_firetext_code,
|
get_message_status_and_reason_from_firetext_code,
|
||||||
)
|
)
|
||||||
@@ -565,10 +565,7 @@ def is_delivery_slow_for_providers(
|
|||||||
slow_notifications = sum(row.count for row in rows if row.slow)
|
slow_notifications = sum(row.count for row in rows if row.slow)
|
||||||
|
|
||||||
slow_providers[provider] = (slow_notifications / total_notifications >= threshold)
|
slow_providers[provider] = (slow_notifications / total_notifications >= threshold)
|
||||||
|
statsd_client.gauge(f'slow-delivery.{provider}.ratio', slow_notifications / total_notifications)
|
||||||
current_app.logger.info("Slow delivery notifications count for provider {}: {} out of {}. Ratio {}".format(
|
|
||||||
provider, slow_notifications, total_notifications, slow_notifications / total_notifications
|
|
||||||
))
|
|
||||||
|
|
||||||
return slow_providers
|
return slow_providers
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user