Search in sources :

Example 6 with MetricValue

use of co.cask.cdap.api.metrics.MetricValue in project cdap by caskdata.

the class MessagingMetricsCollectionServiceTest method checkReceivedMetrics.

protected void checkReceivedMetrics(Table<String, String, Long> expected, Map<String, MetricValues> actual) {
    for (String expectedContext : expected.rowKeySet()) {
        MetricValues metricValues = actual.get(expectedContext);
        Assert.assertNotNull("Missing expected value for " + expectedContext, metricValues);
        for (Map.Entry<String, Long> entry : expected.row(expectedContext).entrySet()) {
            boolean found = false;
            for (MetricValue metricValue : metricValues.getMetrics()) {
                if (entry.getKey().equals(metricValue.getName())) {
                    Assert.assertEquals(entry.getValue().longValue(), metricValue.getValue());
                    found = true;
                    break;
                }
            }
            Assert.assertTrue(found);
        }
    }
}
Also used : MetricValue(co.cask.cdap.api.metrics.MetricValue) MetricValues(co.cask.cdap.api.metrics.MetricValues) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

MetricValue (co.cask.cdap.api.metrics.MetricValue)6 MetricValues (co.cask.cdap.api.metrics.MetricValues)5 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 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 MetricType (co.cask.cdap.api.metrics.MetricType)1 LoadingCache (com.google.common.cache.LoadingCache)1 AbstractIterator (com.google.common.collect.AbstractIterator)1