stats for the cutter

pull/101/head
Christopher Usher 5 years ago
parent 989ef80d30
commit 5c08540c0a

@ -21,8 +21,29 @@ from common.segments import get_best_segments, cut_segments, ContainsHoles
from .youtube import Youtube from .youtube import Youtube
videos_cut = prom.Counter( videos_cut = prom.Counter(
'videos_uploaded' 'videos_cut',
'Number of videos successfully cut',
['video_channel', 'video_quality']
) )
videos_uploaded = prom.Counter(
'videos_uploaded',
'Number of videos successfully uploaded',
['video_channel', 'video_quality', 'upload_location']
)
cutting_errors = prom.Counter(
'cutting_errors',
'Number of errors cutting a video',
['video_channel', 'video_quality']
)
upload_errors = prom.Counter(
'upload_errors',
'Number of errors uploading a video',
['video_channel', 'video_quality', 'upload_location']
)
# A list of all the DB column names in CutJob # A list of all the DB column names in CutJob
CUT_JOB_PARAMS = [ CUT_JOB_PARAMS = [
"category", "category",
@ -285,6 +306,7 @@ class Cutter(object):
yield chunk yield chunk
except Exception as ex: except Exception as ex:
self.logger.exception("Error occurred while trying to cut job {}".format(format_job(job))) self.logger.exception("Error occurred while trying to cut job {}".format(format_job(job)))
cutting_errors.labels(video_channel=job.video_channel, video_quality=job.video_quality).inc()
# Assumed error is not retryable, set state back to UNEDITED and set error. # Assumed error is not retryable, set state back to UNEDITED and set error.
if not set_row(state='UNEDITED', error="Error while cutting: {}".format(ex), uploader=None): if not set_row(state='UNEDITED', error="Error while cutting: {}".format(ex), uploader=None):
self.logger.warning("Tried to roll back row {} to unedited but it was already cancelled.".format(job.id)) self.logger.warning("Tried to roll back row {} to unedited but it was already cancelled.".format(job.id))
@ -303,6 +325,7 @@ class Cutter(object):
.format(job.id, self.name) .format(job.id, self.name)
) )
finalize_begun[0] = True finalize_begun[0] = True
videos_cut.labels(video_channel=job.video_channel, video_quality=job.video_quality).inc()
# Now we return from this generator, and any errors between now and returning # Now we return from this generator, and any errors between now and returning
# from requests.post() are not recoverable. # from requests.post() are not recoverable.
@ -322,6 +345,7 @@ class Cutter(object):
return return
except Exception as ex: except Exception as ex:
self.refresh_conn() self.refresh_conn()
upload_errors.labels(video_channel=job.video_channel, video_quality=job.video_quality, upload_location=job.upload_location).inc()
# for HTTPErrors, getting http response body is also useful # for HTTPErrors, getting http response body is also useful
if isinstance(ex, requests.HTTPError): if isinstance(ex, requests.HTTPError):
@ -371,6 +395,7 @@ class Cutter(object):
) )
self.logger.info("Successfully cut and uploaded job {} as {}".format(format_job(job), link)) self.logger.info("Successfully cut and uploaded job {} as {}".format(format_job(job), link))
videos_uploaded.labels(video_channel=job.video_channel, video_quality=job.video_quality, upload_location=job.upload_location).inc()
def rollback_all_owned(self): def rollback_all_owned(self):
"""Roll back any in-progress jobs that claim to be owned by us, """Roll back any in-progress jobs that claim to be owned by us,

Loading…
Cancel
Save