asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject asterixdb git commit: [NO ISSUE][HYR] Align trace timestamps with epoch
Date Fri, 06 Oct 2017 00:19:28 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 9ac01a25f -> 49791dbff


[NO ISSUE][HYR] Align trace timestamps with epoch

Ensures that microseconds emitted in trace events are since epoch
Outputs human-readable date/timestamp at tracer initialization

Change-Id: I85f3d13994bba77eeda3ea15af1c275c7bc48203
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2058
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/49791dbf
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/49791dbf
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/49791dbf

Branch: refs/heads/master
Commit: 49791dbff7f316a42dc064ec331e60ccd2af1f68
Parents: 9ac01a2
Author: Michael Blow <michael.blow@couchbase.com>
Authored: Thu Oct 5 18:42:04 2017 -0400
Committer: Till Westmann <tillw@apache.org>
Committed: Thu Oct 5 17:19:03 2017 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/hyracks/util/trace/Event.java  |  6 +++++-
 .../main/java/org/apache/hyracks/util/trace/Tracer.java | 12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/49791dbf/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Event.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Event.java
b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Event.java
index 4a46c19..444cd4f 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Event.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Event.java
@@ -18,9 +18,13 @@
  */
 package org.apache.hyracks.util.trace;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.hyracks.util.trace.Tracer.Scope;
 
 final class Event {
+    private static final long NANOTIME_DELTA_TO_EPOCH = System.nanoTime()
+            - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
     public final String name;
     public final String cat;
     public final Tracer.Phase ph;
@@ -43,7 +47,7 @@ final class Event {
     }
 
     private static long timestamp() {
-        return System.nanoTime() / 1000;
+        return (System.nanoTime() - NANOTIME_DELTA_TO_EPOCH) / 1000;
     }
 
     public static Event create(String name, String cat, Tracer.Phase ph, int pid, long tid,
Scope scope, String args) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/49791dbf/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java
b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java
index 4dc2394..cd152a2 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/trace/Tracer.java
@@ -19,7 +19,10 @@
 
 package org.apache.hyracks.util.trace;
 
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -31,6 +34,8 @@ import org.apache.hyracks.util.PidHelper;
 public class Tracer {
 
     protected static final Level TRACE_LOG_LEVEL = Level.INFO;
+    protected static final String CAT = "Tracer";
+    protected static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
 
     protected final Logger traceLog;
     protected String[] categories;
@@ -70,6 +75,13 @@ public class Tracer {
     public Tracer(String name, String[] categories) {
         this.traceLog = Logger.getLogger(Tracer.class.getName() + "@" + name);
         this.categories = categories;
+        instant("Trace-Start", CAT, Scope.p, dateTimeStamp());
+    }
+
+    public static String dateTimeStamp() {
+        synchronized (DATE_FORMAT) {
+            return DATE_FORMAT.format(new Date());
+        }
     }
 
     public static Tracer none() {


Mime
View raw message