Created
June 17, 2015 21:56
-
-
Save jsanda/34c2500937e4bd528212 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public <T> T applyFunction(String tenantId, MetricId id, long start, long end, | |
Func1<Observable<DataPoint<Double>>, T> function) { | |
Observable<DataPoint<Double>> dataPoints = metricsService.findGaugeData(tenantId, id, start, end); | |
return function.call(dataPoints); | |
} | |
@Test | |
public void getAverage() { | |
DateTime start = now().minusMinutes(30); | |
DateTime end = start.plusMinutes(20); | |
String tenantId = "t1"; | |
MetricId id = new MetricId("m1"); | |
Observable<Double> avg = applyFunction(tenantId, id, start.getMillis(), end.getMillis(), dataPoints -> | |
MathObservable.averageDouble(dataPoints.map(DataPoint::getValue)) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment