@Test public void rateHistogramTest() throws Exception { assertEquals(expected(MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 1)))), create().apply(createCtx( MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 1))), MetricValue.fromHistValue(new Histogram()), MetricValue.EMPTY))); assertEquals(expected(MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 1)))), create("30s").apply(createCtx( MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 60))), MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 59))), MetricValue.fromHistValue(new Histogram())))); assertEquals(expected(MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 1)))), create("60s").apply(createCtx( MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 61))), MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 60))), MetricValue.fromHistValue(new Histogram(new Histogram.RangeWithCount(0, 1, 1)))))); }
@Override public TimeSeriesMetricDeltaSet apply(Context ctx) { final Context previous = new PreviousContextWrapper( ctx, ctx.getTSData().getPreviousCollectionPairAt(interval_.orElseGet(() -> ctx.getTSData().getCollectionInterval()))); final Duration collection_interval = new Duration( previous.getTSData().getCurrentCollection().getTimestamp(), ctx.getTSData().getCurrentCollection().getTimestamp()); return TagMatchingClause.DEFAULT.apply( arg_.apply(ctx), arg_.apply(previous), (cur, prev) -> apply_(cur, prev, collection_interval)); }
RateExpression implements TimeSeriesMetricExpression { @Override public TimeSeriesMetricDeltaSet apply(Context ctx) { final Context previous = new PreviousContextWrapper( ctx, ctx.getTSData().getPreviousCollectionPairAt(interval_.orElseGet(() -> ctx.getTSData().getCollectionInterval()))); final Duration collection_interval = new Duration( previous.getTSData().getCurrentCollection().getTimestamp(), ctx.getTSData().getCurrentCollection().getTimestamp()); return TagMatchingClause.DEFAULT.apply( arg_.apply(ctx), arg_.apply(previous), (cur, prev) -> apply_(cur, prev, collection_interval)); } }
RateExpression implements TimeSeriesMetricExpression { @Override public TimeSeriesMetricDeltaSet apply(Context ctx) { final Context previous = new PreviousContextWrapper( ctx, ctx.getTSData().getPreviousCollectionPairAt(interval_.orElseGet(() -> ctx.getTSData().getCollectionInterval()))); final Duration collection_interval = new Duration( previous.getTSData().getCurrentCollection().getTimestamp(), ctx.getTSData().getCurrentCollection().getTimestamp()); return TagMatchingClause.DEFAULT.apply( arg_.apply(ctx), arg_.apply(previous), (cur, prev) -> apply_(cur, prev, collection_interval)); } RateExpression(TimeSeriesMetricExpression arg);  RateExpression(TimeSeriesMetricExpression arg, Duration interval);  RateExpression(TimeSeriesMetricExpression arg, Optional<Duration> interval); }
RateExpression implements TimeSeriesMetricExpression { @Override public TimeSeriesMetricDeltaSet apply(Context ctx) { final Context previous = new PreviousContextWrapper( ctx, ctx.getTSData().getPreviousCollectionPairAt(interval_.orElseGet(() -> ctx.getTSData().getCollectionInterval()))); final Duration collection_interval = new Duration( previous.getTSData().getCurrentCollection().getTimestamp(), ctx.getTSData().getCurrentCollection().getTimestamp()); return TagMatchingClause.DEFAULT.apply( arg_.apply(ctx), arg_.apply(previous), (cur, prev) -> apply_(cur, prev, collection_interval)); } RateExpression(TimeSeriesMetricExpression arg);  RateExpression(TimeSeriesMetricExpression arg, Duration interval);  RateExpression(TimeSeriesMetricExpression arg, Optional<Duration> interval); @Override Collection<TimeSeriesMetricExpression> getChildren(); @Override TimeSeriesMetricDeltaSet apply(Context ctx); @Override ExpressionLookBack getLookBack(); @Override int getPriority(); @Override StringBuilder configString(); }
RateExpression implements TimeSeriesMetricExpression { @Override public TimeSeriesMetricDeltaSet apply(Context ctx) { final Context previous = new PreviousContextWrapper( ctx, ctx.getTSData().getPreviousCollectionPairAt(interval_.orElseGet(() -> ctx.getTSData().getCollectionInterval()))); final Duration collection_interval = new Duration( previous.getTSData().getCurrentCollection().getTimestamp(), ctx.getTSData().getCurrentCollection().getTimestamp()); return TagMatchingClause.DEFAULT.apply( arg_.apply(ctx), arg_.apply(previous), (cur, prev) -> apply_(cur, prev, collection_interval)); } RateExpression(TimeSeriesMetricExpression arg);  RateExpression(TimeSeriesMetricExpression arg, Duration interval);  RateExpression(TimeSeriesMetricExpression arg, Optional<Duration> interval); @Override Collection<TimeSeriesMetricExpression> getChildren(); @Override TimeSeriesMetricDeltaSet apply(Context ctx); @Override ExpressionLookBack getLookBack(); @Override int getPriority(); @Override StringBuilder configString();  }