Log notification ID on deliver tasks and in clients.

- help tie things together  in Kibana.
This commit is contained in:
Martyn Inglis
2016-12-20 13:24:08 +00:00
parent 31b2c3f402
commit 2d946736e0
3 changed files with 9 additions and 3 deletions

View File

@@ -113,6 +113,6 @@ class FiretextClient(SmsClient):
raise FiretextClientResponseException(response=e.response, exception=e) raise FiretextClientResponseException(response=e.response, exception=e)
finally: finally:
elapsed_time = monotonic() - start_time elapsed_time = monotonic() - start_time
self.current_app.logger.info("Firetext request finished in {}".format(elapsed_time)) self.current_app.logger.info("Firetext request for {} finished in {}".format(reference, elapsed_time))
self.statsd_client.timing("clients.firetext.request-time", elapsed_time) self.statsd_client.timing("clients.firetext.request-time", elapsed_time)
return response return response

View File

@@ -120,6 +120,6 @@ class MMGClient(SmsClient):
finally: finally:
elapsed_time = monotonic() - start_time elapsed_time = monotonic() - start_time
self.statsd_client.timing("clients.mmg.request-time", elapsed_time) self.statsd_client.timing("clients.mmg.request-time", elapsed_time)
self.current_app.logger.info("MMG request finished in {}".format(elapsed_time)) self.current_app.logger.info("MMG request for {} finished in {}".format(reference, elapsed_time))
return response return response

View File

@@ -19,6 +19,9 @@ from app.models import SMS_TYPE, KEY_TYPE_TEST, BRANDING_ORG, EMAIL_TYPE
def send_sms_to_provider(notification): def send_sms_to_provider(notification):
service = dao_fetch_service_by_id(notification.service_id) service = dao_fetch_service_by_id(notification.service_id)
provider = provider_to_use(SMS_TYPE, notification.id) provider = provider_to_use(SMS_TYPE, notification.id)
current_app.logger.info(
"Starting sending SMS {} to provider at {}".format(notification.id, datetime.utcnow())
)
if notification.status == 'created': if notification.status == 'created':
template_model = dao_get_template_by_id(notification.template_id, notification.template_version) template_model = dao_get_template_by_id(notification.template_id, notification.template_version)
template = SMSMessageTemplate( template = SMSMessageTemplate(
@@ -47,7 +50,7 @@ def send_sms_to_provider(notification):
dao_update_notification(notification) dao_update_notification(notification)
current_app.logger.info( current_app.logger.info(
"SMS {} sent to provider at {}".format(notification.id, notification.sent_at) "SMS {} sent to provider {} at {}".format(notification.id, provider.get_name(), notification.sent_at)
) )
delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000 delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000
statsd_client.timing("sms.total-time", delta_milliseconds) statsd_client.timing("sms.total-time", delta_milliseconds)
@@ -56,6 +59,9 @@ def send_sms_to_provider(notification):
def send_email_to_provider(notification): def send_email_to_provider(notification):
service = dao_fetch_service_by_id(notification.service_id) service = dao_fetch_service_by_id(notification.service_id)
provider = provider_to_use(EMAIL_TYPE, notification.id) provider = provider_to_use(EMAIL_TYPE, notification.id)
current_app.logger.info(
"Starting sending EMAIL {} to provider at {}".format(notification.id, datetime.utcnow())
)
if notification.status == 'created': if notification.status == 'created':
template_dict = dao_get_template_by_id(notification.template_id, notification.template_version).__dict__ template_dict = dao_get_template_by_id(notification.template_id, notification.template_version).__dict__