Search in sources :

Example 1 with MeasureType

use of io.cdap.cdap.api.dataset.lib.cube.MeasureType in project cdap by caskdata.

the class DefaultMetricStore method add.

@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();
            if (metric.getType() == MetricType.DISTRIBUTION) {
                // https://cdap.atlassian.net/browse/CDAP-18769
                continue;
            }
            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(io.cdap.cdap.api.dataset.lib.cube.Measurement) CubeFact(io.cdap.cdap.api.dataset.lib.cube.CubeFact) MetricValue(io.cdap.cdap.api.metrics.MetricValue) MeasureType(io.cdap.cdap.api.dataset.lib.cube.MeasureType) MetricValues(io.cdap.cdap.api.metrics.MetricValues)

Aggregations

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