statsd: run at 2Hz (#23493)

old-commit-hash: 44592f4b0e
commatwo_master
Willem Melching 3 years ago committed by GitHub
parent 002c79d2d5
commit 755c1f606e
  1. 36
      selfdrive/statsd.py

@ -74,24 +74,26 @@ def main():
last_flush_time = time.monotonic()
gauges = {}
while True:
try:
metric = sock.recv_string(zmq.NOBLOCK)
try:
metric_type = metric.split('|')[1]
metric_name = metric.split(':')[0]
metric_value = metric.split('|')[0].split(':')[1]
if metric_type == METRIC_TYPE.GAUGE:
gauges[metric_name] = metric_value
else:
cloudlog.event("unknown metric type", metric_type=metric_type)
except Exception:
cloudlog.event("malformed metric", metric=metric)
except zmq.error.Again:
time.sleep(1e-3)
started_prev = sm['deviceState'].started
sm.update(0)
sm.update()
# Update metrics
while True:
try:
metric = sock.recv_string(zmq.NOBLOCK)
try:
metric_type = metric.split('|')[1]
metric_name = metric.split(':')[0]
metric_value = metric.split('|')[0].split(':')[1]
if metric_type == METRIC_TYPE.GAUGE:
gauges[metric_name] = metric_value
else:
cloudlog.event("unknown metric type", metric_type=metric_type)
except Exception:
cloudlog.event("malformed metric", metric=metric)
except zmq.error.Again:
break
# flush when started state changes or after FLUSH_TIME_S
if (time.monotonic() > last_flush_time + STATS_FLUSH_TIME_S) or (sm['deviceState'].started != started_prev):

Loading…
Cancel
Save