Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.success(function (metrics) {
$scope.metrics = metrics;
$scope.metrics['mem.used'] = $scope.metrics.mem - $scope.metrics['mem.free'];
$scope.gcInfos = {};
$scope.datasources = {};
function createOrGet(map, key, factory) {
return map[key] || (map[key] = factory());
}
MetricsHelper.find(metrics, [/gc\.(.+)\.time/, /gc\.(.+)\.count/,
/datasource\.(.+)\.active/, /datasource\.(.+)\.usage/
], [function (metric, match, value) {
createOrGet($scope.gcInfos, match[1], function () {
return {
time: 0,
count: 0
};
ApplicationDetails.getMetrics(application).success(function(metrics) {
$scope.metrics = metrics;
$scope.metrics["mem.used"] = $scope.metrics["mem"] - $scope.metrics["mem.free"];
$scope.gcInfos = {};
$scope.datasources = {}
function createOrGet(map, key, factory) {
return map[key] || (map[key] = factory());
}
MetricsHelper.find(metrics,
[ /gc\.(.+)\.time/, /gc\.(.+)\.count/, /datasource\.(.+)\.active/, /datasource\.(.+)\.usage/ ],
[ function(metric, match, value) {
createOrGet($scope.gcInfos, match[1], function() {return {time: 0, count: 0};}).time = value;
},
function(metric, match, value) {
createOrGet($scope.gcInfos, match[1], function() {return {time: 0, count: 0};}).count = value;
},
'sum': slice => ({ '-1': slice['mem.free']['0'] + slice['mem.used']['-1'] }),
'min': slice => ({ '-1': Math.min(slice['mem.free']['0'], slice['mem.used']['-1']) }),
InstanceDetails.getMetrics(instance).success(function(metrics) {
$scope.metrics = metrics;
$scope.metrics["mem.used"] = $scope.metrics["mem"] - $scope.metrics["mem.free"];
$scope.metrics["systemload.averagepercent"] = $scope.metrics["systemload.average"] / $scope.metrics["processors"] * 100;
$scope.gcInfos = {};
$scope.datasources = {};
function createOrGet(map, key, factory) {
return map[key] || (map[key] = factory());
}
MetricsHelper.find(metrics,
[ /gc\.(.+)\.time/, /gc\.(.+)\.count/, /datasource\.(.+)\.active/, /datasource\.(.+)\.usage/ ],
[ function(metric, match, value) {
createOrGet($scope.gcInfos, match[1], function() {return {time: 0, count: 0};}).time = value;
},
function(metric, match, value) {
$scope.metrics["mem.max"] = values[0].data['measurements'][0]['value'];
$scope.metrics["mem.used"] = values[1].data['measurements'][0]['value'];
$scope.metrics["mem.free"] = values[0].data['measurements'][0]['value'] - values[1].data['measurements'][0]['value'];
$scope.humanizedUptime = moment.duration(values[2].data['measurements'][0]['value'], 'seconds').humanize();
var max = 10;
var cur = $scope.memoryConfig.series[0].data.length;
if (cur === max) {
$scope.memoryConfig.series[0].data.splice(0, 1);
$scope.memoryConfig.series[1].data.splice(0, 1);
$scope.memoryConfig.xAxis.categories.splice(0, 1);
}
$scope.memoryConfig.series[0].data.push(formatKibiBytes($scope.metrics["mem.free"]));
$scope.memoryConfig.series[1].data.push(formatKibiBytes($scope.metrics["mem.used"]));
$scope.memoryConfig.xAxis.categories.push($filter('date')(new Date(), "HH:mm:ss"));
});
};