浏览代码

HUE-8665 [editor] Add background color and formatting to heatmap popup.

jdesjean 7 年之前
父节点
当前提交
9fa9340

+ 4 - 2
apps/impala/src/impala/api.py

@@ -149,7 +149,9 @@ def alanize(request):
     summary = analyzer.summary(profile)
     heatmapMetrics = ['AverageThreadTokens', 'BloomFilterBytes', 'PeakMemoryUsage', 'PerHostPeakMemUsage', 'PrepareTime', 'RowsProduced', 'TotalCpuTime', 'TotalNetworkReceiveTime', 'TotalNetworkSendTime', 'TotalStorageWaitTime', 'TotalTime']
     for key in heatmapMetrics:
-      heatmap[key] = analyzer.heatmap_by_host(profile, key)
-    response['data'] = { 'query': { 'healthChecks' : result[0]['result'], 'summary': summary, 'heatmap': heatmap, 'heatmapMetrics': heatmapMetrics } }
+      metrics = analyzer.heatmap_by_host(profile, key)
+      if metrics['data']:
+        heatmap[key] = metrics
+    response['data'] = { 'query': { 'healthChecks' : result[0]['result'], 'summary': summary, 'heatmap': heatmap, 'heatmapMetrics': sorted(list(heatmap.iterkeys())) } }
     response['status'] = 0
   return JsonResponse(response)

文件差异内容过多而无法显示
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue-embedded.css


文件差异内容过多而无法显示
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


+ 8 - 5
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -7523,16 +7523,18 @@
       format: function (element, valueAccessor) {
         var value = valueAccessor();
         var unwrapped = ko.unwrap(value);
+        $(element).text(that.human(unwrapped.value, unwrapped.unit));
+      },
+      human: function (value, unit) {
         var fn;
-        if (unwrapped.unit == 3) {
+        if (unit == 3) {
           fn = ko.bindingHandlers.bytesize.humanSize
-        } else if (unwrapped.unit == 5) {
+        } else if (unit == 5) {
           fn = ko.bindingHandlers.duration.humanTime
         } else {
           fn = function(value){ return value; }
         }
-        var formatted = fn(unwrapped.value);
-        $(element).text(formatted);
+        return fn(value);
       }
     }
   })();
@@ -7607,7 +7609,8 @@
         return Math.log(x) / Math.log(y);
       },
       humanSize: function(bytes) {
-        if (!bytes) {
+        var isNumber = !isNaN(parseFloat(bytes)) && isFinite(bytes);
+        if (!isNumber) {
           return '';
         }
 

+ 28 - 0
desktop/core/src/desktop/static/desktop/less/hue4.less

@@ -820,6 +820,34 @@ ul.risk-list {
   }
 }
 
+.risk.d3-tip {
+  line-height: 1;
+  font-weight: bold;
+  padding: 12px;
+  background: rgba(0, 0, 0, 0.8);
+  color: #fff;
+  border-radius: 2px;
+}
+
+.risk.d3-tip:after {
+  box-sizing: border-box;
+  display: inline;
+  font-size: 10px;
+  width: 100%;
+  line-height: 1;
+  color: rgba(0, 0, 0, 0.8);
+  content: "\25BC";
+  position: absolute;
+  text-align: center;
+}
+
+.risk.d3-tip.n:after {
+  margin: -1px 0 0 0;
+  top: 100%;
+  left: 0;
+}
+
+
 #importerComponents {
   .step-indicator-fixed {
     position: static!important;

+ 4 - 4
desktop/core/src/desktop/templates/ko_components/ko_execution_analysis.mako

@@ -109,7 +109,6 @@ from desktop.views import _ko
           }
           self.analysis(undefined);
           $('[href*=executionAnalysis] span:eq(1)').text(self.analysisCount());
-          $(".d3-tip");
           d3.select(".heatmap").remove();
         });
 
@@ -161,7 +160,7 @@ from desktop.views import _ko
         var d3 = window.d3v3;
         $(".d3-tip").remove();
         var tip = d3.d3tip()
-          .attr('class', 'd3-tip')
+          .attr('class', 'risk d3-tip')
           .offset([-10, 0])
           .html(function(d) {
             var host = d[0];
@@ -169,11 +168,12 @@ from desktop.views import _ko
                 host = host.substring(0, host.indexOf(":"));
             }
             var value = d[2];
-            var formattedValue = String(value).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+            var unit = d[5];
+
+            var formattedValue = ko.bindingHandlers.numberFormat.human(value, unit);
             return "<strong style='color:cyan'>" + host + "</strong><br><strong>" + counterName + ":</strong> <span style='color:red'>" + formattedValue + "</span>";
           });
         d3.select(".heatmap").call(tip);
-
         // Color gradient
         var colors = ['#f6faaa', '#9E0142'];
         var colorScale = d3.scale.linear()

+ 1 - 0
desktop/libs/libanalyze/reasons/scan_performance.json

@@ -7,6 +7,7 @@
     "ScannerThreadsSysTime",
     "AverageScannerThreadConcurrency"
   ],
+  "unit_id": 5,
   "rule": {
     "expr": "(vars['ScannerThreadsUserTime'] + vars['ScannerThreadsSysTime'] - vars['RowsRead'] * 100) / max(1,vars['AverageScannerThreadConcurrency'])",
     "message": "Predicates might be expensive (expectes speed 10m rows per sec per core)",

+ 1 - 0
desktop/libs/libanalyze/reasons/sort_performance.json

@@ -4,6 +4,7 @@
   "metric_names": [
     "LocalTime"
   ],
+  "unit_id": 5,
   "rule": {
     "expr": "vars['LocalTime'] - float(vars['InputRows']) / 0.01",
     "message": "Excess time (over expected time) spent in the sort; might be caused by too many sorting column",

+ 3 - 2
desktop/libs/libanalyze/src/libanalyze/analyze.py

@@ -259,8 +259,9 @@ def heatmap_by_host(profile, counter_name):
   for r in rows:
     result.append([r[0], float(r[1]), float(r[2]),
         float(r[1]) / float(max_max) if float(max_max) != 0 else 0,
-        float(r[2]) / float(sum_sum) if float(sum_sum) != 0 else 0])
-  return { 'data': result, 'max': max_max }
+        float(r[2]) / float(sum_sum) if float(sum_sum) != 0 else 0,
+        rows.unit])
+  return { 'data': result, 'max': max_max, 'unit': rows.unit }
 
 def parse(file_name):
   """Given a file_name, open the file and decode the first line of the file

+ 3 - 1
desktop/libs/libanalyze/src/libanalyze/models.py

@@ -117,7 +117,7 @@ def host_by_metric(profile, metric_name, exprs=[max]):
   fragments = profile.find_all_fragments()
   fragments = filter(lambda x: x.is_averaged() == False, fragments)
   metrics = reduce(lambda x,y: x + y.find_metric_by_name(metric_name), fragments, [])
-  results = []
+  results = L(unit=-1)
   for k, g in groupby(metrics, lambda x: x['node'].host()):
       grouped = list(g)
       values = map(lambda x: x['value'], grouped)
@@ -126,6 +126,8 @@ def host_by_metric(profile, metric_name, exprs=[max]):
         value = expr(values)
         result.append(value)
       results.append(result)
+      if grouped:
+        results.unit = grouped[0]['unit']
 
   return results
 

部分文件因为文件数量过多而无法显示