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

Commit

Permalink
Update to Metrics 0.7.0.Final and update GC Charts
Browse files Browse the repository at this point in the history
  • Loading branch information
ammendonca committed Oct 1, 2015
1 parent 8eb6b92 commit 4acd417
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ module HawkularMetrics {
buckets: 1
}, (resource) => {
if (resource.length) {
this['accGCDuration'] = resource[resource.length - 1].value - resource[0].value;
this['accGCDuration'] = (resource[0].max - resource[0].min);
}
}, this);
this.getJvmChartData();
Expand Down Expand Up @@ -259,10 +259,10 @@ module HawkularMetrics {
counterId: 'MI~R~[' + this.$routeParams.resourceId + '~~]~MT~WildFly Memory Metrics~Accumulated GC Duration',
start: this.startTimeStamp,
end: this.endTimeStamp,
buckets: 1
buckets: 60
}, (resource) => {
if (resource.length) {
this.chartGCDurationData = MetricsService.formatCounterChartOutput(resource, this.startTimeStamp);
this.chartGCDurationData = MetricsService.formatBucketedChartOutput(resource);
}
}, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,85 +96,6 @@ module HawkularMetrics {
});
}

/**
* formatCounterChartOutput
* @param response
* @param startTimeStamp
* @param buckets
* @returns IChartDataPoint[]
*/
public static formatCounterChartOutput(response, startTimeStamp, buckets = 60):IChartDataPoint[] {
if(response.length < 2) {
return [];
}

// get the timestamp interval from the first two samples
let tsStep = response[1].timestamp - response[0].timestamp;

// sometimes there are gaps in data, which needs to be filled with empty values so the buckets get similar time
// intervals. here we figure that and fill them. when metrics support buckets for counters, this is unnecessary
let tmpArr = [response[0], response[1]];
let k = 2;
while(k < response.length) {
if(response[k].timestamp - tmpArr[tmpArr.length-1].timestamp >= (tsStep * 2)) {
tmpArr.push({timestamp: tmpArr[tmpArr.length-1].timestamp + tsStep, value: 0});
}
else {
tmpArr.push(response[k++]);
}
}
response = tmpArr;

// also, if the data starts after the start timestamp, the chart will not have a proper scale, and not comparable
// with others (eg: mem usage). so, if required, fill data with initial missing timestamps.
while (response[0].timestamp > startTimeStamp) {
response.unshift({timestamp: (response[0].timestamp - tsStep), value: 0});
}

// put things into buckets
response = tmpArr;
let result = response.reverse();
/// FIXME: Simulating buckets.. this should come from metrics.
if (response.length >= buckets) {
let wnd: any = window;
let step = wnd.Math.floor(response.length / buckets);
result = [];
let accValue = 0;
var iTimeStamp = 0;
_.forEach(response, (point:any, idx) => {
if (iTimeStamp === 0) {
iTimeStamp = point.timestamp;
}

accValue += point.value;

if (parseInt(idx, 10) % step === (step - 1)) {
result.push({timestamp: iTimeStamp, value: accValue});
accValue = 0;
iTimeStamp = 0;
}
});
// just so that scale matches, sometimes there's some skew..
result[result.length-1].timestamp = startTimeStamp;
}

// 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)
};
});
}

/**
* RetrieveGaugeMetrics
* @param personaId
Expand Down
2 changes: 1 addition & 1 deletion modules/pinger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

<dependency>
<groupId>org.hawkular.metrics</groupId>
<artifactId>clients-common</artifactId>
<artifactId>hawkular-metrics-clients-common</artifactId>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<version.org.hawkular.bus>0.6.1.Final</version.org.hawkular.bus>
<version.org.hawkular.commons>0.2.2.Final-SRC-revision-2f649e10df3c4b25557cf9ae5c77da7f9ef77619</version.org.hawkular.commons>
<version.org.hawkular.cmdgw>0.8.0.Final</version.org.hawkular.cmdgw>
<version.org.hawkular.metrics>0.6.0.Final</version.org.hawkular.metrics>
<version.org.hawkular.metrics>0.7.0.Final</version.org.hawkular.metrics>
<version.org.hawkular.inventory>0.5.0.Final</version.org.hawkular.inventory>
<version.org.hawkular.nest>${version.org.hawkular.bus}</version.org.hawkular.nest>
<version.org.keycloak>1.3.1.Final</version.org.keycloak>
Expand Down Expand Up @@ -216,7 +216,7 @@

<dependency>
<groupId>org.hawkular.metrics</groupId>
<artifactId>clients-common</artifactId>
<artifactId>hawkular-metrics-clients-common</artifactId>
<version>${version.org.hawkular.metrics}</version>
</dependency>

Expand Down

0 comments on commit 4acd417

Please sign in to comment.