public static Collection<PreaggregatedMetric> convertCounters(String tenant, long timestamp, long flushIntervalMillis, Collection<BluefloodCounter> counters) {
List<PreaggregatedMetric> list = new ArrayList<PreaggregatedMetric>(counters.size());
for (BluefloodCounter counter : counters) {
Locator locator = Locator.createLocatorFromPathComponents(tenant, counter.getName().split(NAME_DELIMITER, -1));
long sampleCount = flushIntervalMillis > 0
? (long)(counter.getRate().doubleValue() * ((double)flushIntervalMillis/1000d))
: 1;
Rollup rollup = new BluefloodCounterRollup()
.withCount(resolveNumber(counter.getValue()))
.withRate(counter.getRate().doubleValue())
.withSampleCount((int)sampleCount);
PreaggregatedMetric metric = new PreaggregatedMetric(timestamp, locator, DEFAULT_TTL, rollup);
list.add(metric);
}
return list;
}