incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Updating some tracing code.
Date Tue, 17 Dec 2013 14:28:37 GMT
Updated Branches:
  refs/heads/master 70597f44b -> 20bd0c7a8


Updating some tracing code.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/20bd0c7a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/20bd0c7a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/20bd0c7a

Branch: refs/heads/master
Commit: 20bd0c7a831899fef3a023ec825022e8dd9f9d44
Parents: 70597f4
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Dec 17 09:28:08 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Dec 17 09:28:30 2013 -0500

----------------------------------------------------------------------
 blur-gui/src/main/webapp/traces.html            | 24 +++++++++++---------
 .../main/java/org/apache/blur/trace/Trace.java  | 13 +++++++----
 .../org/apache/blur/trace/TraceCollector.java   |  8 ++++++-
 3 files changed, 29 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/20bd0c7a/blur-gui/src/main/webapp/traces.html
----------------------------------------------------------------------
diff --git a/blur-gui/src/main/webapp/traces.html b/blur-gui/src/main/webapp/traces.html
index 7208a49..fc8394a 100644
--- a/blur-gui/src/main/webapp/traces.html
+++ b/blur-gui/src/main/webapp/traces.html
@@ -76,7 +76,7 @@ function displayRequestIds(traceIdAttr) {
 	  var traceRequestList = client.traceRequestList(traceId);
 	  var rbody = $("#request_id_body");
 	  var lst = traceRequestList.sort();
-      var s = "<h5>" + traceId + "<h5><table border=1 class=\"table-bordered
table-striped table-condensed\"><tr><th nowrap=1>Request Id</th><th
nowrap=1>Time Offset (ms)</th></tr>";
+      var s = "<h5>" + traceId + "<h5><table border=1 class=\"table-bordered
table-striped table-condensed\"><tr><th nowrap=1>Request Id</th><th
nowrap=1>Time Offset (ms)</th><th nowrap=1>Total Time (ms)</th></tr>";
       var requestArray = new Array();
 	  for (var i = 0; i < lst.length; i++) {
 		var info = getRequestInfo(client,traceId,lst[i]);
@@ -100,7 +100,7 @@ function displayRequestIds(traceIdAttr) {
           s += "<tr><td nowrap=1><a id=\""+id+"\" href=\"#\">"+requestArray[i].nodeName+"
(Request "+i+")</a></td>";
         }
         var diff = requestArray[i].created - lastTime;
-        s += "<td>"+diff / 1000000+"</td></tr>";
+        s += "<td>"+diff / 1000000+"</td><td>" + requestArray[i].totalTime
/ 1000000 + "</td></tr>";
 		lastTime = requestArray[i].created;
       }
       rbody.html(s + "</table>");
@@ -121,6 +121,7 @@ function getRequestInfo(client,traceId,requestId) {
   var traceRequest = $.parseJSON(json);
   var result = {};
   result.created = traceRequest.created;
+  result.totalTime = traceRequest.totalTime;
   result.nodeName = traceRequest.nodeName;
   return result;
 }
@@ -136,13 +137,14 @@ function displayTrace(traceIdPlusRequestId) {
   var ids = new Array();
   var header = "<h5>" + traceId + "<h5><h6>"+requestId + "</h6>";
   header += "<table border=1 class=\"table-bordered table-striped table-condensed\">";
-  header += "<tr><th>Node</th><th>Pid</th><th>Main Thread</th><th>Create
Time</th></tr>";
+  header += "<tr><th>Node</th><th>Pid</th><th>Main Thread</th><th>Create
Time</th><th>Total Time</th></tr>";
   header += "<tr><td>" + traceRequest.nodeName + "</td>";
   header += "<td>" + traceRequest.pid + "</td>";
   header += "<td>" + traceRequest.thread + "</td>";
-  header += "<td>" + formatTime(traceRequest.created) + "</td></tr>";
+  header += "<td>" + formatTime(traceRequest.created) + "</td>";
+  header += "<td>" + traceRequest.totalTime / 1000000 + " ms</td></tr>";
   header += "</table><br/>";
-  var s = gatherTraceInfo(traceRequest,requestIds,traceId,ids);
+  var s = gatherTraceInfo(traceRequest,requestIds,traceId,ids,traceRequest.totalTime,true);
   $("#trace_contents").html(header + s);
   for (var i = 0; i < ids.length; i++) {
     $("#"+ids[i]).click(
@@ -186,7 +188,7 @@ function bufDigits(num,len) {
   }
   return num;
 }
-function gatherTraceInfo(collector,requestIds,traceId,ids) {
+function gatherTraceInfo(collector,requestIds,traceId,ids,totalRequestTime,parent) {
   var traces = collector.traces;
   var s = "<table border=1 class=\"table-bordered table-striped table-condensed\">";
   s += "<tr><th>Trace Name</th><th>Thread</th><th>Scope</th><th>Time
(ms)</th></tr>";
@@ -198,7 +200,7 @@ function gatherTraceInfo(collector,requestIds,traceId,ids) {
     }
     return 0;
   })
-  var totalTimeTook = traces[0].took;
+
   for (var i = 0; i < traces.length; i++) {
     var trace = traces[i];
 
@@ -210,15 +212,15 @@ function gatherTraceInfo(collector,requestIds,traceId,ids) {
         var id = "requestid_"+traceId+"_"+requestIdInAnotherProcess + "_2";
         ids.push(id);
         colName += "<a href=\"#\" id=\""+id+"\">" + trace.id + " - " + trace.name +
"</a>";
-        colValue += gatherTraceInfo(trace.collector,requestIds,traceId,ids);
+        colValue += gatherTraceInfo(trace.collector,requestIds,traceId,ids,totalRequestTime,false);
       } else {
         colName += trace.id + " - " + trace.name + "</td>";
-        colValue += gatherTraceInfo(trace.collector,requestIds,traceId,ids);
+        colValue += gatherTraceInfo(trace.collector,requestIds,traceId,ids,totalRequestTime,false);
       }
     } else {
-	  var p = (trace.took / totalTimeTook * 100);
+	  var p = (trace.took / totalRequestTime * 100);
 	  colName += trace.id + " - " + trace.name;
-	  if (i!=0) {
+	  if (i!=0 || !parent) {
 	    colValue = "<td valign=top nowrap=1 bgcolor=\"#"+colors[100-Math.round(p)] +"\">"
+ (trace.took / 1000000.0).toPrecision(6) + " (" + p.toPrecision(3)  + "% of Request)";
       } else {
 	    colValue += (trace.took / 1000000.0).toPrecision(6);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/20bd0c7a/blur-util/src/main/java/org/apache/blur/trace/Trace.java
----------------------------------------------------------------------
diff --git a/blur-util/src/main/java/org/apache/blur/trace/Trace.java b/blur-util/src/main/java/org/apache/blur/trace/Trace.java
index 7d781c6..7841806 100644
--- a/blur-util/src/main/java/org/apache/blur/trace/Trace.java
+++ b/blur-util/src/main/java/org/apache/blur/trace/Trace.java
@@ -55,10 +55,10 @@ public class Trace {
 
   public static class Parameter {
 
-    final String _name;
-    final String _value;
+    final Object _name;
+    final Object _value;
 
-    public Parameter(String name, String value) {
+    public Parameter(Object name, Object value) {
       _name = name;
       _value = value;
     }
@@ -106,7 +106,7 @@ public class Trace {
     if (value == null) {
       value = "null";
     }
-    return new Parameter(name.toString(), value.toString());
+    return new Parameter(name, value);
   }
 
   private static void setupTraceOnNewThread(TraceCollector parentCollector, String requestId,
int traceScope) {
@@ -117,13 +117,18 @@ public class Trace {
   }
 
   private static void tearDownTraceOnNewThread() {
+    TraceCollector collector = _tracer.get();
     _tracer.set(null);
+    if (collector != null) {
+      collector.finished();
+    }
   }
 
   public static void tearDownTrace() {
     TraceCollector collector = _tracer.get();
     _tracer.set(null);
     if (_storage != null && collector != null) {
+      collector.finished();
       _storage.store(collector);
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/20bd0c7a/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java
----------------------------------------------------------------------
diff --git a/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java b/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java
index b5953f3..98f5af3 100644
--- a/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java
+++ b/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java
@@ -31,9 +31,11 @@ public class TraceCollector {
   protected final AtomicLong _traceCounter = new AtomicLong();
   protected final AtomicInteger _scope = new AtomicInteger();
   protected final long _now = (System.currentTimeMillis() * 1000000) + (System.nanoTime()
% 1000000);
+  protected final long _started = System.nanoTime();
   protected final String _pid;
   protected final String _threadName;
   protected final String _nodeName;
+  protected long _finished;
 
   public TraceCollector(String nodeName, TraceId id) {
     _nodeName = nodeName;
@@ -70,7 +72,7 @@ public class TraceCollector {
     }
     return "{\n  \"id\":" + _id.toJson() + ",\n  \"nodeName\":\"" + (_nodeName == null ?
"unknown" : _nodeName)
         + "\",\n  \"pid\":\"" + _pid + "\",\n  \"thread\":\"" + _threadName + "\",\n  \"created\":"
+ _now
-        + ",\n  \"traces\":[\n" + builder.toString() + "  ]\n}";
+        + ",\n  \"totalTime\":" + (_finished - _started) + ",\n  \"traces\":[\n" + builder.toString()
+ "  ]\n}";
   }
 
   public TraceId getId() {
@@ -88,4 +90,8 @@ public class TraceCollector {
   public AtomicInteger getScope() {
     return _scope;
   }
+
+  public void finished() {
+    _finished = System.nanoTime();
+  }
 }


Mime
View raw message