Export last frame timestamp metric
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Lauri Võsandi 2022-02-20 09:53:19 +02:00 committed by Lauri Võsandi
parent 3d792bfbc9
commit b903fca13d

View File

@ -13,6 +13,7 @@ from prometheus_client import Counter, Gauge
from sanic import Sanic, response from sanic import Sanic, response
from sanic.response import stream from sanic.response import stream
from sanic_prometheus import monitor from sanic_prometheus import monitor
from time import time
_, url = sys.argv _, url = sys.argv
@ -54,7 +55,9 @@ counter_errors = Counter(
counter_movement_frames = Counter( counter_movement_frames = Counter(
"camdetect_movement_frames", "camdetect_movement_frames",
"Frames with movement detected in them") "Frames with movement detected in them")
gauge_last_frame = Gauge(
"camdetect_last_frame",
"Timestamp of last frame")
gauge_total_blocks = Gauge( gauge_total_blocks = Gauge(
"camdetect_total_blocks", "camdetect_total_blocks",
"Total DCT blocks") "Total DCT blocks")
@ -86,6 +89,7 @@ async def client_connect(resp):
continue continue
else: else:
app.ctx.last_frame = Frame(buf + data[:marker+2]) app.ctx.last_frame = Frame(buf + data[:marker+2])
gauge_last_frame.set(time())
reference = app.ctx.last_frame.mask reference = app.ctx.last_frame.mask
app.ctx.frames.append(reference) app.ctx.frames.append(reference)