switch error event to use log record and add more details

This commit is contained in:
jobevers 2017-01-29 13:47:00 -08:00
parent b7478ba817
commit 565f26bdad
3 changed files with 9 additions and 6 deletions

View file

@ -60,10 +60,13 @@ class Events(object):
properties = download_properties(*args, **kwargs) properties = download_properties(*args, **kwargs)
return self._event('Download Finished', properties) return self._event('Download Finished', properties)
def error(self, message, sd_hash=None): def error(self, log_record):
"""Record when a log message of ERROR or higher was emitted"""
properties = { properties = {
'message': message, 'message': log_record.message,
'stream_info': sd_hash 'module': log_record.module,
'lineno': log_record.lineno,
'name': log_record.name,
} }
return self._event('Error', properties) return self._event('Error', properties)

View file

@ -8,4 +8,4 @@ class Handler(logging.Handler):
logging.Handler.__init__(self, level) logging.Handler.__init__(self, level)
def emit(self, record): def emit(self, record):
self.manager.send_error(record.message) self.manager.send_error(record)

View file

@ -82,8 +82,8 @@ class Manager(object):
event = self.events_generator.download_finished(id_, name, stream_info) event = self.events_generator.download_finished(id_, name, stream_info)
self.analytics_api.track(event) self.analytics_api.track(event)
def send_error(self, message, sd_hash=None): def send_error(self, message):
event = self.events_generator.error(message, sd_hash) event = self.events_generator.error(message)
self.analytics_api.track(event) self.analytics_api.track(event)
def register_repeating_metric(self, event_name, value_generator, frequency=300): def register_repeating_metric(self, event_name, value_generator, frequency=300):