Skip to content

Commit

Permalink
[HWKMETRICS-422] Remove unneeded calls to findMetric. It is now almos…
Browse files Browse the repository at this point in the history
…t equivalent to query for data of non-existing metric when compared to trying to find if a metric exists. Removing this call makes the stats method faster because it avoids a query to the metrics index.
  • Loading branch information
Stefan Negrea committed Aug 23, 2016
1 parent 0063902 commit 00097dd
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -857,32 +857,31 @@ public <T extends Number> Observable<List<NumericBucketPoint>> findNumericStats(
if (!stacked) {
if (COUNTER == metricType || GAUGE == metricType) {
return Observable.from(metrics)
.flatMap(metricName -> findMetric(new MetricId<>(tenantId, metricType, metricName)))
.flatMap(metric -> findDataPoints(metric.getMetricId(), start, end, 0, Order.DESC))
.flatMap(metricName -> findDataPoints(new MetricId<>(tenantId, metricType, metricName), start,
end, 0, Order.DESC))
.compose(new NumericBucketPointTransformer(buckets, percentiles));
} else {
MetricType<? extends Number> mtype = metricType == GAUGE_RATE ? GAUGE : COUNTER;
return Observable.from(metrics)
.flatMap(metricName -> findMetric(new MetricId<>(tenantId, mtype, metricName)))
.flatMap(metric -> findRateData(metric.getMetricId(), start, end, 0, ASC))
.flatMap(metricName -> findRateData(new MetricId<>(tenantId, mtype, metricName), start, end, 0,
ASC))
.compose(new NumericBucketPointTransformer(buckets, percentiles));
}
} else {
Observable<Observable<NumericBucketPoint>> individualStats;
if (COUNTER == metricType || GAUGE == metricType) {
individualStats = Observable.from(metrics)
.flatMap(metricName -> findMetric(new MetricId<>(tenantId, metricType, metricName)))
.map(metric -> {
return findDataPoints(metric.getMetricId(), start, end, 0, Order.DESC)
.map(metricName -> {
return findDataPoints(new MetricId<>(tenantId, metricType, metricName), start, end, 0,
Order.DESC)
.compose(new NumericBucketPointTransformer(buckets, percentiles))
.flatMap(Observable::from);
});
} else {
MetricType<? extends Number> mtype = metricType == GAUGE_RATE ? GAUGE : COUNTER;
individualStats = Observable.from(metrics)
.flatMap(metricName -> findMetric(new MetricId<>(tenantId, mtype, metricName)))
.map(metric -> {
return findRateData(metric.getMetricId(), start, end, 0, ASC)
.map(metricName -> {
return findRateData(new MetricId<>(tenantId, mtype, metricName), start, end, 0, ASC)
.compose(new NumericBucketPointTransformer(buckets, percentiles))
.flatMap(Observable::from);
});
Expand Down

0 comments on commit 00097dd

Please sign in to comment.