statsd: fix duplicate filename (#24595)

This commit is contained in:
Willem Melching
2022-05-19 15:36:07 +02:00
committed by GitHub
parent d3d210c183
commit dd55d14bb1
+3 -1
View File
@@ -88,6 +88,7 @@ def main() -> NoReturn:
# subscribe to deviceState for started state
sm = SubMaster(['deviceState'])
idx = 0
last_flush_time = time.monotonic()
gauges = {}
samples: Dict[str, List[float]] = defaultdict(list)
@@ -149,9 +150,10 @@ def main() -> NoReturn:
# check that we aren't filling up the drive
if len(os.listdir(STATS_DIR)) < STATS_DIR_FILE_LIMIT:
if len(result) > 0:
stats_path = os.path.join(STATS_DIR, str(int(current_time.timestamp())))
stats_path = os.path.join(STATS_DIR, f"{current_time.timestamp():.0f}_{idx}")
with atomic_write_in_dir(stats_path) as f:
f.write(result)
idx += 1
else:
cloudlog.error("stats dir full")