Merge pull request #453 from lbryio/add-details-to-error-event
Add details to error event
This commit is contained in:
commit
2c137a99d1
4 changed files with 11 additions and 9 deletions
|
@ -60,10 +60,13 @@ class Events(object):
|
|||
properties = download_properties(*args, **kwargs)
|
||||
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 = {
|
||||
'message': message,
|
||||
'stream_info': sd_hash
|
||||
'message': log_record.message,
|
||||
'module': log_record.module,
|
||||
'lineno': log_record.lineno,
|
||||
'name': log_record.name,
|
||||
}
|
||||
return self._event('Error', properties)
|
||||
|
||||
|
|
|
@ -8,4 +8,4 @@ class Handler(logging.Handler):
|
|||
logging.Handler.__init__(self, level)
|
||||
|
||||
def emit(self, record):
|
||||
self.manager.send_error(record.message)
|
||||
self.manager.send_error(record)
|
||||
|
|
|
@ -82,8 +82,8 @@ class Manager(object):
|
|||
event = self.events_generator.download_finished(id_, name, stream_info)
|
||||
self.analytics_api.track(event)
|
||||
|
||||
def send_error(self, message, sd_hash=None):
|
||||
event = self.events_generator.error(message, sd_hash)
|
||||
def send_error(self, message):
|
||||
event = self.events_generator.error(message)
|
||||
self.analytics_api.track(event)
|
||||
|
||||
def register_repeating_metric(self, event_name, value_generator, frequency=300):
|
||||
|
|
|
@ -761,14 +761,13 @@ class Daemon(AuthJSONRPCServer):
|
|||
|
||||
def eb():
|
||||
if not r.called:
|
||||
self.analytics_manager.send_error("sd blob download timed out", sd_hash)
|
||||
log.error("sd blob download timed out: %s", sd_hash)
|
||||
r.errback(Exception("sd timeout"))
|
||||
|
||||
r = defer.Deferred(None)
|
||||
reactor.callLater(timeout, eb)
|
||||
d = download_sd_blob(self.session, sd_hash, self.session.payment_rate_manager)
|
||||
d.addErrback(lambda err: self.analytics_manager.send_error(
|
||||
"error downloading sd blob: " + err, sd_hash))
|
||||
d.addErrback(log.fail(), "Error downloading sd blob: %s", sd_hash)
|
||||
d.addCallback(BlobStreamDescriptorReader)
|
||||
d.addCallback(lambda blob: blob.get_info())
|
||||
d.addCallback(cb)
|
||||
|
|
Loading…
Reference in a new issue