diff --git a/util/saas/cloudwatch.py b/util/saas/cloudwatch.py index 7f7fc3ad3..78e4abc11 100644 --- a/util/saas/cloudwatch.py +++ b/util/saas/cloudwatch.py @@ -1,6 +1,7 @@ import logging import boto import time +import random from Queue import Empty from threading import Thread @@ -82,7 +83,9 @@ class CloudWatchSender(Thread): logger.exception('Failed to write to CloudWatch: %s', metrics) logger.debug('Attempted to requeue %d metrics.', len(metrics['name'])) - time.sleep(FAILED_SEND_SLEEP_SECS) + # random int between 1/2 and 1 1/2 of FAILED_SEND_SLEEP duration + sleep_secs = random.randint(FAILED_SEND_SLEEP_SECS/2, 3*FAILED_SEND_SLEEP_SECS/2) + time.sleep(sleep_secs) def append_metric(metrics, m): name, value, kwargs = m