Search in sources :

Example 1 with TagValue

use of io.cdap.cdap.api.metrics.TagValue in project cdap by caskdata.

the class TestFrameworkTestRun method testTaskMetric.

private void testTaskMetric(String runId, boolean doesExist) throws Exception {
    List<TagValue> tags = new ArrayList<>();
    tags.add(new TagValue(Constants.Metrics.Tag.NAMESPACE, NamespaceId.DEFAULT.getNamespace()));
    tags.add(new TagValue(Constants.Metrics.Tag.APP, DatasetWithMRApp.class.getSimpleName()));
    tags.add(new TagValue(Constants.Metrics.Tag.MAPREDUCE, DatasetWithMRApp.MAPREDUCE_PROGRAM));
    tags.add(new TagValue(Constants.Metrics.Tag.RUN_ID, runId));
    Collection<String> metricNames = getMetricsManager().searchMetricNames(new MetricSearchQuery(0, Integer.MAX_VALUE, Integer.MAX_VALUE, tags));
    // we disabled task level metrics; this should return empty list
    Assert.assertEquals(doesExist, metricNames.contains("user.test.metric"));
}
Also used : MetricSearchQuery(io.cdap.cdap.api.metrics.MetricSearchQuery) ArrayList(java.util.ArrayList) TagValue(io.cdap.cdap.api.metrics.TagValue)

Example 2 with TagValue

use of io.cdap.cdap.api.metrics.TagValue in project cdap by caskdata.

the class MetricsQueryHelper method tagValuesToHuman.

private List<MetricTagValue> tagValuesToHuman(Collection<TagValue> tagValues) {
    List<MetricTagValue> result = Lists.newArrayList();
    for (TagValue tagValue : tagValues) {
        String human = tagNameToHuman.get(tagValue.getName());
        human = human != null ? human : tagValue.getName();
        String value = tagValue.getValue() == null ? ANY_TAG_VALUE : tagValue.getValue();
        result.add(new MetricTagValue(human, value));
    }
    return result;
}
Also used : MetricTagValue(io.cdap.cdap.proto.MetricTagValue) MetricTagValue(io.cdap.cdap.proto.MetricTagValue) TagValue(io.cdap.cdap.api.metrics.TagValue)

Example 3 with TagValue

use of io.cdap.cdap.api.metrics.TagValue in project cdap by caskdata.

the class DefaultMetricStore method findNextAvailableTags.

@Override
public Collection<TagValue> findNextAvailableTags(MetricSearchQuery query) {
    Collection<DimensionValue> tags = cube.get().findDimensionValues(buildCubeSearchQuery(query));
    Collection<TagValue> result = Lists.newArrayList();
    for (DimensionValue dimensionValue : tags) {
        result.add(new TagValue(dimensionValue.getName(), dimensionValue.getValue()));
    }
    return result;
}
Also used : DimensionValue(io.cdap.cdap.api.dataset.lib.cube.DimensionValue) TagValue(io.cdap.cdap.api.metrics.TagValue)

Example 4 with TagValue

use of io.cdap.cdap.api.metrics.TagValue in project cdap by caskdata.

the class TestFrameworkTestRun method testTaskTagLevelExists.

private void testTaskTagLevelExists(String appName, String programName, String runId, String datasetName, boolean doesExist) throws Exception {
    List<TagValue> tags = new ArrayList<>();
    tags.add(new TagValue(Constants.Metrics.Tag.NAMESPACE, NamespaceId.DEFAULT.getNamespace()));
    tags.add(new TagValue(Constants.Metrics.Tag.APP, appName));
    tags.add(new TagValue(Constants.Metrics.Tag.MAPREDUCE, programName));
    tags.add(new TagValue(Constants.Metrics.Tag.RUN_ID, runId));
    tags.add(new TagValue(Constants.Metrics.Tag.DATASET, datasetName));
    tags.add(new TagValue(Constants.Metrics.Tag.MR_TASK_TYPE, "m"));
    Collection<TagValue> tagsValues = getMetricsManager().searchTags(new MetricSearchQuery(0, Integer.MAX_VALUE, Integer.MAX_VALUE, tags));
    Assert.assertEquals(doesExist, !tagsValues.isEmpty());
    if (doesExist) {
        Assert.assertEquals(Constants.Metrics.Tag.INSTANCE_ID, tagsValues.iterator().next().getName());
    }
}
Also used : MetricSearchQuery(io.cdap.cdap.api.metrics.MetricSearchQuery) ArrayList(java.util.ArrayList) TagValue(io.cdap.cdap.api.metrics.TagValue)

Aggregations

TagValue (io.cdap.cdap.api.metrics.TagValue)4 MetricSearchQuery (io.cdap.cdap.api.metrics.MetricSearchQuery)2 ArrayList (java.util.ArrayList)2 DimensionValue (io.cdap.cdap.api.dataset.lib.cube.DimensionValue)1 MetricTagValue (io.cdap.cdap.proto.MetricTagValue)1