mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Added statsd integration into the API
- new client for statsd, follows conventions used elsewhere for configuration - client wraps underlying library so we can use a config property to send/not send statsd Added statsd metrics for: - count of API successful calls SMS/Email - count of successful task execution for SMS/Email - count of errors from Client libraries - timing of API calls to third party clients - timing of how long messages live on the SQS queue
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import uuid
|
||||
from flask import current_app
|
||||
|
||||
from app import statsd_client
|
||||
from app.dao import notifications_dao
|
||||
from app.clients.sms.firetext import get_firetext_responses
|
||||
from app.clients.sms.mmg import get_mmg_responses
|
||||
@@ -67,5 +69,6 @@ def process_sms_client_response(status, reference, client_name):
|
||||
reference,
|
||||
notification_status_message))
|
||||
|
||||
statsd_client.incr('notifications.callback.{}.{}'.format(client_name.lower(), notification_statistics_status))
|
||||
success = "{} callback succeeded. reference {} updated".format(client_name, reference)
|
||||
return success, errors
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
|
||||
import statsd
|
||||
import itertools
|
||||
from flask import (
|
||||
Blueprint,
|
||||
@@ -12,7 +12,7 @@ from flask import (
|
||||
from notifications_utils.recipients import allowed_to_send_to, first_column_heading
|
||||
from notifications_utils.template import Template
|
||||
from app.clients.email.aws_ses import get_aws_responses
|
||||
from app import api_user, encryption, create_uuid, DATETIME_FORMAT, DATE_FORMAT
|
||||
from app import api_user, encryption, create_uuid, DATETIME_FORMAT, DATE_FORMAT, statsd_client
|
||||
from app.authentication.auth import require_admin
|
||||
from app.dao import (
|
||||
templates_dao,
|
||||
@@ -103,6 +103,7 @@ def process_ses_response():
|
||||
)
|
||||
)
|
||||
|
||||
statsd_client.incr('notifications.callback.ses.{}'.format(notification_statistics_status))
|
||||
return jsonify(
|
||||
result="success", message="SES callback succeeded"
|
||||
), 200
|
||||
@@ -374,4 +375,5 @@ def send_notification(notification_type):
|
||||
datetime.utcnow().strftime(DATETIME_FORMAT)
|
||||
), queue='email')
|
||||
|
||||
statsd_client.incr('notifications.api.{}'.format(notification_type))
|
||||
return jsonify(data={"notification": {"id": notification_id}}), 201
|
||||
|
||||
Reference in New Issue
Block a user