From 446befd543515e545dc15b52bb769b1177a0d3ca Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sun, 6 Jan 2019 05:52:03 -0800 Subject: [PATCH] downloader: Track number of downloaded segments This is the most important metric, we can add more later. --- downloader/downloader/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/downloader/downloader/main.py b/downloader/downloader/main.py index a003719..f19fe41 100644 --- a/downloader/downloader/main.py +++ b/downloader/downloader/main.py @@ -21,6 +21,13 @@ import twitch import common +segments_downloaded = prom.Counter( + "segments_downloaded", + "Number of segments either partially or fully downloaded", + ["partial", "stream", "variant"], +) + + class TimedOutError(Exception): pass @@ -484,11 +491,13 @@ class SegmentGetter(object): partial_path = self.make_path("partial", hash) self.logger.warning("Saving partial segment {} as {}".format(temp_path, partial_path)) common.rename(temp_path, partial_path) + segments_downloaded.labels(partial="True", stream=self.channel, variant=self.stream).inc() raise ex_type, ex, tb else: full_path = self.make_path("full", hash) self.logger.debug("Saving completed segment {} as {}".format(temp_path, full_path)) common.rename(temp_path, full_path) + segments_downloaded.labels(partial="False", stream=self.channel, variant=self.stream).inc() def main(channel, base_dir=".", qualities="", metrics_port=8001):