diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aa5bb7e..2626b478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - Add a Pause button in the checks list (#312) - Documentation in Markdown - Added an example of capturing and submitting log output (#315) +- The sendalerts commands measures dwell time and reports it over statsd protocol ### Bug Fixes - Increase the allowable length of Matrix room alias to 100 (#320) diff --git a/hc/api/management/commands/sendalerts.py b/hc/api/management/commands/sendalerts.py index 6bb01d16..882a5bc5 100644 --- a/hc/api/management/commands/sendalerts.py +++ b/hc/api/management/commands/sendalerts.py @@ -4,6 +4,7 @@ from threading import Thread from django.core.management.base import BaseCommand from django.utils import timezone from hc.api.models import Check, Flip +from statsd.defaults.env import statsd def notify(flip_id, stdout): @@ -24,10 +25,13 @@ def notify(flip_id, stdout): check.project.set_next_nag_date() # Send notifications + send_time = timezone.now() errors = flip.send_alerts() for ch, error in errors: stdout.write("ERROR: %s %s %s\n" % (ch.kind, ch.value, error)) + statsd.timing("hc.sendalerts.dwellTime", send_time - flip.created) + def notify_on_thread(flip_id, stdout): t = Thread(target=notify, args=(flip_id, stdout)) diff --git a/requirements.txt b/requirements.txt index b6215a7c..d68ffbe2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ django-compressor==2.4 psycopg2==2.8.4 pytz==2019.3 requests==2.22.0 +statsd=3.3.0 \ No newline at end of file