throttling is once every 5 min for an error

This commit is contained in:
shaun 2016-11-02 07:08:33 +11:00
parent d7728afea0
commit 1554a52bf7

View file

@ -133,13 +133,13 @@ class GoogleAnalytics():
def sendEventData(self, eventCategory, eventAction, eventLabel=None, throttle=False): def sendEventData(self, eventCategory, eventAction, eventLabel=None, throttle=False):
# if throttling is enabled then only log the same event every 60 seconds # if throttling is enabled then only log the same event every 5 min
if(throttle): if(throttle):
throttleKey = eventCategory + "-" + eventAction + "-" + str(eventLabel) throttleKey = eventCategory + "-" + eventAction + "-" + str(eventLabel)
lastLogged = logEventHistory.get(throttleKey) lastLogged = logEventHistory.get(throttleKey)
if(lastLogged != None): if(lastLogged != None):
timeSinceLastLog = time.time() - lastLogged timeSinceLastLog = time.time() - lastLogged
if(timeSinceLastLog < 60): if(timeSinceLastLog < 300):
log.info("SKIPPING_LOG_EVENT : " + str(timeSinceLastLog) + " " + throttleKey) log.info("SKIPPING_LOG_EVENT : " + str(timeSinceLastLog) + " " + throttleKey)
return return
logEventHistory[throttleKey] = time.time() logEventHistory[throttleKey] = time.time()