public static Points<BluefloodCounterRollup> generateFakeCounterRollupPoints() { Points<BluefloodCounterRollup> points = new Points<BluefloodCounterRollup>(); long startTime = 1234567L; for (int i = 0; i < 5; i++) { long timeNow = startTime + i*1000; Points.Point<BluefloodCounterRollup> point = new Points.Point<BluefloodCounterRollup>(timeNow, new BluefloodCounterRollup() .withCount(i + 1000) .withRate((double) i) .withSampleCount(i+1)); points.add(point); } return points; }
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)); // flushIntervalMillis could be zero (if not specified in the statsD config). 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; }
protected static List<IMetric> createTestMetricsFromInterface(String tenantId) { IMetric metric; List<IMetric> metrics = new ArrayList<>(); BluefloodCounterRollup counter = new BluefloodCounterRollup(); List<Locator> locators = createComplexTestLocators(tenantId); for (Locator locator : locators) { metric = new PreaggregatedMetric(0, locator, new TimeValue(1, TimeUnit.DAYS), counter); metrics.add(metric); } return metrics; }