Skip to content

Commit

Permalink
Merge pull request #2054 from denzelsN/master
Browse files Browse the repository at this point in the history
add active trace chart in inspector page
  • Loading branch information
denzelsN committed Sep 5, 2016
2 parents 38d308b + a860c2d commit a676fb6
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 5 deletions.
1 change: 1 addition & 0 deletions web/src/grunt/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ module.exports = function( grunt, options ) {
'/features/jvmMemoryChart/jvm-memory-chart.directive.js',
'/features/cpuLoadChart/cpu-load-chart.directive.js',
'/features/tpsChart/tps-chart.directive.js',
'/features/activeTraceChart/active-trace-chart.directive.js',
'/features/loading/loading.directive.js',
'/features/configuration/configuration.controller.js',
'/features/configuration/general/general.directive.js',
Expand Down
39 changes: 39 additions & 0 deletions web/src/main/webapp/common/services/agent-dao.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,45 @@

return newData;
};
this.parseActiveTraceChartDataForAmcharts = function (activeTrace, agentStat) {
var aActiveTraceFastData = agentStat.charts[ "ACTIVE_TRACE_FAST" ].points;
var aActiveTraceNormal = agentStat.charts[ "ACTIVE_TRACE_NORMAL" ].points;
var aActiveTraceSlow = agentStat.charts[ "ACTIVE_TRACE_SLOW" ].points;
var aActiveTraceVerySlow = agentStat.charts[ "ACTIVE_TRACE_VERY_SLOW" ].points;

if ( aActiveTraceFastData || aActiveTraceNormal || aActiveTraceSlow || aActiveTraceVerySlow ) {
activeTrace.isAvailable = true;
} else {
return;
}
var newData = [],
DATA_UNAVAILABLE = -1;

for ( var i = 0 ; i < aActiveTraceFastData.length ; i++ ) {
var thisData = {
time: moment(aActiveTraceFastData[i].xVal).format( cfg.dateFormat )
};
var traceFace = typeof aActiveTraceFastData[i].avgYVal == "number" ? aActiveTraceFastData[i].avgYVal.toFixed(2) : 0.00;
var traceNormal = typeof aActiveTraceNormal[i].avgYVal == "number" ? aActiveTraceNormal[i].avgYVal.toFixed(2) : 0.00;
var traceSlow = typeof aActiveTraceSlow[i].avgYVal == "number" ? aActiveTraceSlow[i].avgYVal.toFixed(2) : 0.00;
var traceVerySlow = typeof aActiveTraceVerySlow[i].avgYVal == "number" ? aActiveTraceVerySlow[i].avgYVal.toFixed(2) : 0.00;
if ( traceFace != DATA_UNAVAILABLE ) {
thisData.traceFace = traceFace;
}
if ( traceNormal != DATA_UNAVAILABLE ) {
thisData.traceNormal = traceNormal;
}
if ( traceSlow != DATA_UNAVAILABLE ) {
thisData.traceSlow = traceSlow;
}
if ( traceVerySlow != DATA_UNAVAILABLE ) {
thisData.traceVerySlow = traceVerySlow;
}
newData.push(thisData);
}

return newData;
};
}
]);
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
(function() {
'use strict';
angular.module( "pinpointApp" ).directive( "activeTraceChartDirective", [ "$timeout",
function ( $timeout ) {
return {
template: '<div></div>',
replace: true,
restrict: 'E',
scope: {
namespace: '@' // string value
},
link: function postLink(scope, element, attrs) {

// define variables
var sId, oChart;

// define variables of methods
var setIdAutomatically, setWidthHeight, render, showCursorAt, resize;

/**
* set id automatically
*/
setIdAutomatically = function () {
sId = 'multipleValueAxesId-' + scope.namespace;
element.attr('id', sId);
};

/**
* set width height
* @param w
* @param h
*/
setWidthHeight = function (w, h) {
if (w) element.css('width', w);
if (h) element.css('height', h);
};

/**
* render
* @param chartData
*/
render = function (chartData) {
var options = {
"type": "serial",
"theme": "light",
"autoMargins": false,
"marginTop": 10,
"marginLeft": 70,
"marginRight": 70,
"marginBottom": 30,
"legend": {
"useGraphSettings": true,
"autoMargins": true,
"align" : "right",
"position": "top",
"valueWidth": 70
},
"usePrefixes": true,
"dataProvider": chartData,
"valueAxes": [
{
"stackType": "regular",
"gridAlpha": 0,
"axisAlpha": 1,
"position": "left",
"title": "Active Trace",
"minimum" : 0
}
],
"graphs": [
{
"balloonText": "Trace Fast : [[value]]",
"legendValueText": "[[value]]",
"lineColor": "rgb(214, 141, 8)",
"fillColor": "rgb(214, 141, 8)",
"title": "Fast",
"valueField": "traceFace",
"fillAlphas": 0.4,
"connect": true
},{
"balloonText": "Trace Normal : [[value]]",
"legendValueText": "[[value]]",
"lineColor": "rgb(252, 178, 65)",
"fillColor": "rgb(252, 178, 65)",
"title": "Normal",
"valueField": "traceNormal",
"fillAlphas": 0.4,
"connect": true
},{
"balloonText": "Trace Slow : [[value]]",
"legendValueText": "[[value]]",
"lineColor": "rgb(90, 103, 166)",
"fillColor": "rgb(90, 103, 166)",
"title": "Slow",
"valueField": "traceSlow",
"fillAlphas": 0.4,
"connect": true
},{
"balloonText": "Trace Very Slow : [[value]]",
"legendValueText": "[[value]]",
"lineColor": "rgb(160, 153, 255)",
"fillColor": "rgb(160, 153, 255)",
"title": "Very Slow",
"valueField": "traceVerySlow",
"fillAlphas": 0.4,
"connect": true
}
],
"chartCursor": {
"categoryBalloonAlpha": 0.7,
"fullWidth": true,
"cursorAlpha": 0.1
},
"categoryField": "time",
"categoryAxis": {
"axisColor": "#DADADA",
"startOnAxis": true,
"gridPosition": "start",
"labelFunction": function (valueText, serialDataItem, categoryAxis) {
return moment(valueText).format("HH:mm:ss");
}
}
};
$timeout(function () {
oChart = AmCharts.makeChart(sId, options);
oChart.chartCursor.addListener( "changed", function (event) {
scope.$emit( "activeTraceChartDirective.cursorChanged." + scope.namespace, event);
});
});
};

/**
* show cursor at
* @param category
*/
showCursorAt = function (category) {
if (category) {
if (angular.isNumber(category)) {
category = oChart.dataProvider[category].time;
}
oChart.chartCursor.showCursorAt(category);
} else {
oChart.chartCursor.hideCursor();
}
};

/**
* resize
*/
resize = function () {
if (oChart) {
oChart.validateNow();
oChart.validateSize();
}
};

scope.$on( "activeTraceChartDirective.initAndRenderWithData." + scope.namespace, function (event, data, w, h) {
setIdAutomatically();
setWidthHeight(w, h);
render(data);
});

scope.$on( "activeTraceChartDirective.showCursorAt." + scope.namespace, function (event, category) {
showCursorAt(category);
});

scope.$on( "activeTraceChartDirective.resize." + scope.namespace, function (event) {
resize();
});
}
};
}
]);
})();
27 changes: 22 additions & 5 deletions web/src/main/webapp/features/agentInfo/agent-info.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
* @param agentStat
*/
function showCharts(agentStat) {

var heap = { id: 'heap', title: 'Heap Usage', span: 'span12', line: [
{ id: 'JVM_MEMORY_HEAP_USED', key: 'Used', values: [], isFgc: false },
{ id: 'JVM_MEMORY_HEAP_MAX', key: 'Max', values: [], isFgc: false },
Expand All @@ -169,15 +168,18 @@
var cpuLoad = { id: 'cpuLoad', title: 'JVM/System Cpu Usage', span: 'span12', isAvailable: false};

var tps = { id: 'tps', title: 'Transactions Per Second', span: 'span12', isAvailable: false };
var activeTrace = { id: "activeTrace", title: "Active Trace Chart", span: "span12", isAvailable: false};

scope.memoryGroup = [ heap, nonheap ];
scope.cpuLoadChart = cpuLoad;
scope.tpsChart = tps;
scope.activeTraceChart = activeTrace;

scope.$broadcast('jvmMemoryChartDirective.initAndRenderWithData.forHeap', AgentDaoService.parseMemoryChartDataForAmcharts(heap, agentStat), '100%', '270px');
scope.$broadcast('jvmMemoryChartDirective.initAndRenderWithData.forNonHeap', AgentDaoService.parseMemoryChartDataForAmcharts(nonheap, agentStat), '100%', '270px');
scope.$broadcast('cpuLoadChartDirective.initAndRenderWithData.forCpuLoad', AgentDaoService.parseCpuLoadChartDataForAmcharts(cpuLoad, agentStat), '100%', '270px');
scope.$broadcast('tpsChartDirective.initAndRenderWithData.forTps', AgentDaoService.parseTpsChartDataForAmcharts(tps, agentStat), '100%', '270px');
scope.$broadcast( "jvmMemoryChartDirective.initAndRenderWithData.forHeap", AgentDaoService.parseMemoryChartDataForAmcharts(heap, agentStat), '100%', '270px');
scope.$broadcast( "jvmMemoryChartDirective.initAndRenderWithData.forNonHeap", AgentDaoService.parseMemoryChartDataForAmcharts(nonheap, agentStat), '100%', '270px');
scope.$broadcast( "cpuLoadChartDirective.initAndRenderWithData.forCpuLoad", AgentDaoService.parseCpuLoadChartDataForAmcharts(cpuLoad, agentStat), '100%', '270px');
scope.$broadcast( "tpsChartDirective.initAndRenderWithData.forTps", AgentDaoService.parseTpsChartDataForAmcharts(tps, agentStat), '100%', '270px');
scope.$broadcast( "activeTraceChartDirective.initAndRenderWithData.forActiveTrace", AgentDaoService.parseActiveTraceChartDataForAmcharts(tps, agentStat), '100%', '270px');
}
function getEventList( agentId, aFromTo ) {
AgentAjaxService.getEventList({
Expand All @@ -202,6 +204,11 @@
scope.$broadcast('tpsChartDirective.showCursorAt.forTps', event.index);
}
}
function broadcastToActiveTraceChart(e, event) {
if (scope.activeTraceChart.isAvailable) {
scope.$broadcast('activeTraceChartDirective.showCursorAt.forActiveTrace', event.index);
}
}
scope.toggleHelp = function() {
$("._wrongApp").popover({
"title": "<span class='label label-info'>" + UrlVoService.getApplicationName() + "</span> <span class='glyphicon glyphicon-resize-horizontal'></span> <span class='label label-info'>" + scope.agent.applicationName + "</span>",
Expand Down Expand Up @@ -318,22 +325,32 @@
scope.$broadcast('jvmMemoryChart.showCursorAt.forNonHeap', event.index);
broadcastToCpuLoadChart(e, event);
broadcastToTpsChart(e, event);
broadcastToActiveTraceChart(e, event);
});
scope.$on('jvmMemoryChartDirective.cursorChanged.forNonHeap', function (e, event) {
scope.$broadcast('jvmMemoryChartDirective.showCursorAt.forHeap', event.index);
broadcastToCpuLoadChart(e, event);
broadcastToTpsChart(e, event);
broadcastToActiveTraceChart(e, event);
});
scope.$on('cpuLoadChartDirective.cursorChanged.forCpuLoad', function (e, event) {
scope.$broadcast('jvmMemoryChartDirective.showCursorAt.forHeap', event.index);
scope.$broadcast('jvmMemoryChartDirective.showCursorAt.forNonHeap', event.index);
broadcastToTpsChart(e, event);
broadcastToActiveTraceChart(e, event);
});
scope.$on('tpsChartDirective.cursorChanged.forTps', function (e, event) {
scope.$broadcast('jvmMemoryChartDirective.showCursorAt.forHeap', event.index);
scope.$broadcast('jvmMemoryChartDirective.showCursorAt.forNonHeap', event.index);
broadcastToCpuLoadChart(e, event);
broadcastToActiveTraceChart(e, event);
});
scope.$on('activeTraceChartDirective.cursorChanged.forActiveTrace', function (e, event) {
scope.$broadcast('jvmMemoryChartDirective.showCursorAt.forHeap', event.index);
scope.$broadcast('jvmMemoryChartDirective.showCursorAt.forNonHeap', event.index);
broadcastToCpuLoadChart(e, event);
broadcastToTpsChart(e, event);
});
}
};
}
Expand Down
9 changes: 9 additions & 0 deletions web/src/main/webapp/features/agentInfo/agentInfoMain.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ <h4><span class="glyphicon glyphicon-question-sign tpsTooltip" style="cursor:poi
<tps-chart-directive namespace="forTps"></tps-chart-directive>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-6">
<h4><span class="glyphicon glyphicon-question-sign" style="cursor:pointer;float:right;"></span> {{activeTraceChart.title}}</h4>
<active-trace-chart-directive namespace="forActiveTrace"></active-trace-chart-directive>
</div>
<div class="col-md-6">
</div>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions web/src/main/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ <h4>To use PinPoint, enable cookies and JavaScript</h4>
<script src="features/jvmMemoryChart/jvm-memory-chart.directive.js?v=${buildTime}"></script>
<script src="features/cpuLoadChart/cpu-load-chart.directive.js?v=${buildTime}"></script>
<script src="features/tpsChart/tps-chart.directive.js?v=${buildTime}"></script>
<script src="features/activeTraceChart/active-trace-chart.directive.js?v=${buildTime}"></script>
<script src="features/loading/loading.directive.js?v=${buildTime}"></script>
<script src="features/configuration/configuration.directive.js?v=${buildTime}"></script>
<script src="features/configuration/general/general.directive.js?v=${buildTime}"></script>
Expand Down

0 comments on commit a676fb6

Please sign in to comment.