Make statistics file rolling
authorMathieu <mbaudier@argeo.org>
Thu, 1 Dec 2022 07:31:32 +0000 (08:31 +0100)
committerMathieu <mbaudier@argeo.org>
Thu, 1 Dec 2022 07:31:32 +0000 (08:31 +0100)
lib/linux/org.argeo.slc.systemd/src/org/argeo/slc/systemd/dbus/ServiceStatistics.java

index 787655e7f89481a3d6e89f6063af5c3b22d73737..b40ba232b769bbc058f5fb1587de80a8b0dad81c 100644 (file)
@@ -128,8 +128,10 @@ public class ServiceStatistics {
                        while (manager != null) {
                                synchronized (this) {
 
-                                       String dateSuffix = Instant.ofEpochMilli(begin).atOffset(ZoneOffset.UTC)
-                                                       .format(DateTimeFormatter.ISO_LOCAL_DATE) + "-" + begin;
+                                       // We change the prefix in order to have a file per day
+                                       // but keep the begin timestamp in order to identify restarts
+                                       String dateSuffix = Instant.now().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_LOCAL_DATE)
+                                                       + "-" + begin;
 
                                        Path statisticsPath = basePath.resolve("statistics-" + unitName + "-" + dateSuffix + ".csv");
                                        boolean writeHeader = !Files.exists(statisticsPath);