@Override public void add(Collection<? extends MetricValues> metricValues) { List<CubeFact> facts = Lists.newArrayListWithCapacity(metricValues.size()); for (MetricValues metricValue : metricValues) { String scope = metricValue.getTags().get(Constants.Metrics.Tag.SCOPE); List<Measurement> metrics = Lists.newArrayList(); // todo improve this logic? for (MetricValue metric : metricValue.getMetrics()) { String measureName = (scope == null ? "system." : scope + ".") + metric.getName(); MeasureType type = metric.getType() == MetricType.COUNTER ? MeasureType.COUNTER : MeasureType.GAUGE; metrics.add(new Measurement(measureName, type, metric.getValue())); } CubeFact fact = new CubeFact(metricValue.getTimestamp()) .addDimensionValues(metricValue.getTags()) .addMeasurements(metrics); facts.add(fact); } cube.get().add(facts); }
@Override public void add(Collection<? extends MetricValues> metricValues) { List<CubeFact> facts = Lists.newArrayListWithCapacity(metricValues.size()); for (MetricValues metricValue : metricValues) { String scope = metricValue.getTags().get(Constants.Metrics.Tag.SCOPE); List<Measurement> metrics = Lists.newArrayList(); // todo improve this logic? for (MetricValue metric : metricValue.getMetrics()) { String measureName = (scope == null ? "system." : scope + ".") + metric.getName(); MeasureType type = metric.getType() == MetricType.COUNTER ? MeasureType.COUNTER : MeasureType.GAUGE; metrics.add(new Measurement(measureName, type, metric.getValue())); } CubeFact fact = new CubeFact(metricValue.getTimestamp()) .addDimensionValues(metricValue.getTags()) .addMeasurements(metrics); facts.add(fact); } cube.get().add(facts); }
private CubeFact getFact(String measureName, long ts, long value, MeasureType measureType, Map<String, String> dims) { return new CubeFact(ts) .addDimensionValues(dims) .addMeasurement(measureName, measureType, value); }