add tracked metrics reporting to analytics
This commit is contained in:
parent
3a91896d8a
commit
b71a3fee43
1 changed files with 11 additions and 0 deletions
|
@ -205,17 +205,22 @@ class AnalyticsManager(object):
|
|||
def __init__(self):
|
||||
self.analytics_api = None
|
||||
self.events_generator = None
|
||||
self.track = analytics.Track()
|
||||
self.send_heartbeat = LoopingCall(self._send_heartbeat)
|
||||
self.update_tracked_metrics = LoopingCall(self._update_tracked_metrics)
|
||||
|
||||
def start(self, platform, wallet_type, lbry_id, session_id):
|
||||
context = analytics.make_context(platform, wallet_type)
|
||||
self.events_generator = analytics.Events(context, base58.b58encode(lbry_id), session_id)
|
||||
self.analytics_api = analytics.Api.load()
|
||||
self.send_heartbeat.start(60)
|
||||
self.update_tracked_metrics.start(300)
|
||||
|
||||
def shutdown(self):
|
||||
if self.send_heartbeat.running:
|
||||
self.send_heartbeat.stop()
|
||||
if self.update_tracked_metrics.running:
|
||||
self.update_tracked_metrics.stop()
|
||||
|
||||
def send_download_started(self, name, stream_info=None):
|
||||
event = self.events_generator.download_started(name, stream_info)
|
||||
|
@ -225,6 +230,12 @@ class AnalyticsManager(object):
|
|||
heartbeat = self.events_generator.heartbeat()
|
||||
self.analytics_api.track(heartbeat)
|
||||
|
||||
def _update_tracked_metrics(self):
|
||||
value = self.track.summarize(analytics.BLOB_BYTES_UPLOADED)
|
||||
if value > 0:
|
||||
event = self.events_generator.metric_observered(analytics.BLOB_BYTES_UPLOADED, value)
|
||||
self.analytics_api.track(event)
|
||||
|
||||
|
||||
class Daemon(jsonrpc.JSONRPC):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue