use of co.cask.cdap.api.dataset.lib.cube.MeasureType in project cdap by caskdata.
the class DefaultMetricStore method add.
@Override
public void add(Collection<? extends MetricValues> metricValues) throws Exception {
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);
}
Aggregations