Search in sources :

Example 1 with MeasureType

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);
}
Also used : Measurement(co.cask.cdap.api.dataset.lib.cube.Measurement) CubeFact(co.cask.cdap.api.dataset.lib.cube.CubeFact) MetricValue(co.cask.cdap.api.metrics.MetricValue) MeasureType(co.cask.cdap.api.dataset.lib.cube.MeasureType) MetricValues(co.cask.cdap.api.metrics.MetricValues)

Aggregations

CubeFact (co.cask.cdap.api.dataset.lib.cube.CubeFact)1 MeasureType (co.cask.cdap.api.dataset.lib.cube.MeasureType)1 Measurement (co.cask.cdap.api.dataset.lib.cube.Measurement)1 MetricValue (co.cask.cdap.api.metrics.MetricValue)1 MetricValues (co.cask.cdap.api.metrics.MetricValues)1