Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #535 from ammendonca/HAWKULAR-681
Browse files Browse the repository at this point in the history
HAWKULAR-681 : Fix chart missing Expired and Rejected Sessions
  • Loading branch information
mtho11 committed Oct 8, 2015
2 parents 2c23965 + 94c6067 commit 9702b1c
Showing 1 changed file with 3 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,61 +119,7 @@ module HawkularMetrics {
});
}

private formatBucketedChartOutput(response):IChartDataPoint[] {

// The schema is different for bucketed output
return _.map(response, (point:IChartDataPoint) => {
return {
timestamp: point.start,
date: new Date(point.start),
value: !angular.isNumber(point.value) ? 0 : point.value,
avg: (point.empty) ? 0 : point.avg,
min: !angular.isNumber(point.min) ? 0 : point.min,
max: !angular.isNumber(point.max) ? 0 : point.max,
percentile95th: !angular.isNumber(point.percentile95th) ? 0 : point.percentile95th,
median: !angular.isNumber(point.median) ? 0 : point.median,
empty: point.empty
};
});
}

private formatCounterChartOutput(response, buckets = 60):IChartDataPoint[] {
let result = response;
/// FIXME: Simulating buckets.. this should come from metrics.
if (response.length > buckets) {
let step = Math.floor(response.length / buckets);
result = [];
let accValue = 0;
_.forEach(response, function (point:any, idx) {
if (parseInt(idx, 10) % step === (step - 1)) {
result.push({timestamp: point.timestamp, value: accValue});
accValue = 0;
}
else {
accValue += point.value;
}
});
}

// The schema is different for bucketed output
return _.map(result, (point:IChartDataPoint, idx) => {
let theValue = idx === 0 ? 0 : (result[idx - 1].value - point.value);
return {
timestamp: point.timestamp,
date: new Date(point.timestamp),
value: theValue,
avg: theValue,
min: theValue,
max: theValue,
percentile95th: theValue,
median: theValue,
empty: !angular.isNumber(point.value)
};
});
}

public getWebData():void {
///this.alertList = []; // FIXME: when we have alerts for app server
this.endTimeStamp = this.$routeParams.endTime || +moment();
this.startTimeStamp = this.endTimeStamp - (this.$routeParams.timeOffset || 3600000);

Expand Down Expand Up @@ -220,7 +166,7 @@ module HawkularMetrics {
this.chartWebSessionData[0] = {
key: 'Active Sessions',
color: AppServerWebDetailsController.ACTIVE_COLOR,
values: this.formatBucketedChartOutput(data)
values: MetricsService.formatBucketedChartOutput(data)
};
}, this);
this.HawkularMetric.CounterMetricData(this.$rootScope.currentPersona.id).queryMetrics({
Expand All @@ -232,7 +178,7 @@ module HawkularMetrics {
this.chartWebSessionData[1] = {
key: 'Expired Sessions',
color: AppServerWebDetailsController.EXPIRED_COLOR,
values: this.formatCounterChartOutput(data)
values: MetricsService.formatBucketedChartOutput(data)
};
}, this);
this.HawkularMetric.CounterMetricData(this.$rootScope.currentPersona.id).queryMetrics({
Expand All @@ -244,7 +190,7 @@ module HawkularMetrics {
this.chartWebSessionData[2] = {
key: 'Rejected Sessions',
color: AppServerWebDetailsController.REJECTED_COLOR,
values: this.formatCounterChartOutput(data)
values: MetricsService.formatBucketedChartOutput(data)
};
}, this);
/* FIXME: Currently this is always returning negative values, as WFLY returns -1 per webapp. is it config value?
Expand Down

0 comments on commit 9702b1c

Please sign in to comment.