Skip to content

Instantly share code, notes, and snippets.

@jsanda
Created June 17, 2015 21:56
Show Gist options
  • Save jsanda/34c2500937e4bd528212 to your computer and use it in GitHub Desktop.
Save jsanda/34c2500937e4bd528212 to your computer and use it in GitHub Desktop.
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