use of co.cask.cdap.api.metrics.TagValue in project cdap by caskdata.
the class DefaultMetricStore method findNextAvailableTags.
@Override
public Collection<TagValue> findNextAvailableTags(MetricSearchQuery query) throws Exception {
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;
}
use of co.cask.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;
}
use of co.cask.cdap.api.metrics.TagValue in project cdap by caskdata.
the class WorkflowStatsSLAHttpHandler method getSparkDetails.
private Map<String, Long> getSparkDetails(ProgramId sparkProgram, String runId) throws Exception {
Map<String, String> context = new HashMap<>();
context.put(Constants.Metrics.Tag.NAMESPACE, sparkProgram.getNamespace());
context.put(Constants.Metrics.Tag.APP, sparkProgram.getApplication());
context.put(Constants.Metrics.Tag.SPARK, sparkProgram.getProgram());
context.put(Constants.Metrics.Tag.RUN_ID, runId);
List<TagValue> tags = new ArrayList<>();
for (Map.Entry<String, String> entry : context.entrySet()) {
tags.add(new TagValue(entry.getKey(), entry.getValue()));
}
MetricSearchQuery metricSearchQuery = new MetricSearchQuery(0, 0, Integer.MAX_VALUE, tags);
Collection<String> metricNames = metricStore.findMetricNames(metricSearchQuery);
Map<String, Long> overallResult = new HashMap<>();
for (String metricName : metricNames) {
Collection<MetricTimeSeries> resultPerQuery = metricStore.query(new MetricDataQuery(0, 0, Integer.MAX_VALUE, metricName, AggregationFunction.SUM, context, new ArrayList<String>()));
for (MetricTimeSeries metricTimeSeries : resultPerQuery) {
overallResult.put(metricTimeSeries.getMetricName(), metricTimeSeries.getTimeValues().get(0).getValue());
}
}
return overallResult;
}
Aggregations