From 6940be095958b4786fbd2e0cfe74511512a9049a Mon Sep 17 00:00:00 2001 From: MaysWind Date: Wed, 26 Apr 2023 00:54:18 +0800 Subject: [PATCH 1/2] support all of ujl decorators, allow log only contains time or uptime --- .../imp/DataReaderUnifiedJvmLogging.java | 110 ++++- .../imp/TestDataReaderUJLDecorations.java | 387 ++++++++++++++++++ 2 files changed, 476 insertions(+), 21 deletions(-) create mode 100644 src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderUJLDecorations.java diff --git a/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderUnifiedJvmLogging.java b/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderUnifiedJvmLogging.java index 5ebeed0c..62a321fe 100644 --- a/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderUnifiedJvmLogging.java +++ b/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderUnifiedJvmLogging.java @@ -3,6 +3,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -29,13 +32,13 @@ /** * DataReaderUnifiedJvmLogging can parse all gc events of unified jvm logs with default decorations. *

- * Currently needs the "gc" selector with "info" level and "uptime,level,tags" decorators (Java 9.0.1). + * Currently needs the "gc" selector with "info" level and "uptime,level,tags" (or "time,level,tags") decorators (Java 9.0.1). * Also supports "gc*" selector with "trace" level and "time,uptime,level,tags" decorators, but will ignore some of * the debug and all trace level info (evaluates the following tags: "gc", "gc,start", "gc,heap", "gc,metaspace". *

* Only processes the following information format for Serial, Parallel, CMS, G1 and Shenandoah algorithms, everything else is ignored: *
@@ -51,28 +54,56 @@ public class DataReaderUnifiedJvmLogging extends AbstractDataReader {
     // TODO also parse "Allocation Stall (main)" events
 
     // matches the whole line and extracts decorators from it (decorators always appear between [] and are independent of the gc algorithm being logged)
-    // Input: [0.693s][info][gc           ] GC(0) Pause Init Mark 1.070ms
-    // Group 1 / time:  (optional group, no full timestamp present)
-    // Group 2 / uptime: 0.693 (optional group, present in this example)
-    // Group 3 / level: info
-    // Group 4 / tags: gc
-    // Group 5 / gcnumber: 0
-    // Group 6 / tail: Pause Init Mark 1.070ms
-    // Regex: ^(?:\[(?