mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 09:46:11 +00:00
metric loggin throttling
This commit is contained in:
parent
ea4059b6d0
commit
ca6d90969d
5 changed files with 23 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.video.emby"
|
<addon id="plugin.video.emby"
|
||||||
name="Emby"
|
name="Emby"
|
||||||
version="2.3.2"
|
version="2.3.4"
|
||||||
provider-name="Emby.media">
|
provider-name="Emby.media">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.19.0"/>
|
<import addon="xbmc.python" version="2.19.0"/>
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
version 2.3.4
|
||||||
|
- add throttling for error event logging
|
||||||
|
|
||||||
|
version 2.3.3
|
||||||
|
- minor fix to exception handling
|
||||||
|
|
||||||
version 2.3.1
|
version 2.3.1
|
||||||
- minor fixes
|
- minor fixes
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import md5
|
||||||
import xbmc
|
import xbmc
|
||||||
import platform
|
import platform
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
import time
|
||||||
from utils import window, settings, language as lang
|
from utils import window, settings, language as lang
|
||||||
|
|
||||||
log = logging.getLogger("EMBY."+__name__)
|
log = logging.getLogger("EMBY."+__name__)
|
||||||
|
@ -15,6 +16,8 @@ log = logging.getLogger("EMBY."+__name__)
|
||||||
# for info on the metrics that can be sent to Google Analytics
|
# for info on the metrics that can be sent to Google Analytics
|
||||||
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#events
|
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#events
|
||||||
|
|
||||||
|
logEventHistory = {}
|
||||||
|
|
||||||
class GoogleAnalytics():
|
class GoogleAnalytics():
|
||||||
|
|
||||||
testing = False
|
testing = False
|
||||||
|
@ -128,7 +131,18 @@ class GoogleAnalytics():
|
||||||
|
|
||||||
self.sendData(data)
|
self.sendData(data)
|
||||||
|
|
||||||
def sendEventData(self, eventCategory, eventAction, eventLabel=None):
|
def sendEventData(self, eventCategory, eventAction, eventLabel=None, throttle=False):
|
||||||
|
|
||||||
|
# if throttling is enabled then only log the same event every 5 min
|
||||||
|
if(throttle):
|
||||||
|
throttleKey = eventCategory + "-" + eventAction + "-" + str(eventLabel)
|
||||||
|
lastLogged = logEventHistory.get(throttleKey)
|
||||||
|
if(lastLogged != None):
|
||||||
|
timeSinceLastLog = time.time() - lastLogged
|
||||||
|
if(timeSinceLastLog < 300):
|
||||||
|
log.info("SKIPPING_LOG_EVENT : " + str(timeSinceLastLog) + " " + throttleKey)
|
||||||
|
return
|
||||||
|
logEventHistory[throttleKey] = time.time()
|
||||||
|
|
||||||
data = self.getBaseData()
|
data = self.getBaseData()
|
||||||
data['t'] = 'event' # action type
|
data['t'] = 'event' # action type
|
||||||
|
|
|
@ -30,7 +30,7 @@ def catch_except(errors=(Exception, ), default_value=False):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
except errors as error:
|
except errors as error:
|
||||||
errStrings = ga.formatException()
|
errStrings = ga.formatException()
|
||||||
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
ga.sendEventData("Exception", errStrings[0], errStrings[1], True)
|
||||||
log.exception(error)
|
log.exception(error)
|
||||||
log.error("function: %s \n args: %s \n kwargs: %s",
|
log.error("function: %s \n args: %s \n kwargs: %s",
|
||||||
func.__name__, args, kwargs)
|
func.__name__, args, kwargs)
|
||||||
|
|
|
@ -307,21 +307,6 @@ def indent(elem, level=0):
|
||||||
if level and (not elem.tail or not elem.tail.strip()):
|
if level and (not elem.tail or not elem.tail.strip()):
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
|
|
||||||
def catch_except(errors=(Exception, ), default_value=False):
|
|
||||||
# Will wrap method with try/except and print parameters for easier debugging
|
|
||||||
def decorator(func):
|
|
||||||
def wrapper(*args, **kwargs):
|
|
||||||
try:
|
|
||||||
return func(*args, **kwargs)
|
|
||||||
except errors as error:
|
|
||||||
log.exception(error)
|
|
||||||
log.error("function: %s \n args: %s \n kwargs: %s",
|
|
||||||
func.__name__, args, kwargs)
|
|
||||||
return default_value
|
|
||||||
|
|
||||||
return wrapper
|
|
||||||
return decorator
|
|
||||||
|
|
||||||
def profiling(sortby="cumulative"):
|
def profiling(sortby="cumulative"):
|
||||||
# Will print results to Kodi log
|
# Will print results to Kodi log
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
|
|
Loading…
Reference in a new issue