fix(cloudwatch): randomize sleep interval

This commit is contained in:
EvB 2017-01-05 11:31:21 -05:00
parent e658941a43
commit a7122db250

View file

@ -1,6 +1,7 @@
import logging import logging
import boto import boto
import time import time
import random
from Queue import Empty from Queue import Empty
from threading import Thread from threading import Thread
@ -82,7 +83,9 @@ class CloudWatchSender(Thread):
logger.exception('Failed to write to CloudWatch: %s', metrics) logger.exception('Failed to write to CloudWatch: %s', metrics)
logger.debug('Attempted to requeue %d metrics.', len(metrics['name'])) 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): def append_metric(metrics, m):
name, value, kwargs = m name, value, kwargs = m