use of org.apache.heron.proto.tmanager.TopologyManager.MetricResponse.IndividualMetric.IntervalValue in project heron by twitter.
the class MetricsCacheMetricsProvider method parse.
@VisibleForTesting
@SuppressWarnings("unchecked")
Collection<Measurement> parse(TopologyManager.MetricResponse response, String component, String metric, Instant startTime) {
Collection<Measurement> metricsData = new ArrayList();
if (response == null || !response.getStatus().getStatus().equals(StatusCode.OK)) {
LOG.info(String.format("Query failure from MetricsCache for %s:%s ", component, metric));
return metricsData;
}
if (response.getMetricCount() == 0) {
LOG.info(String.format("Did not get any metrics from MetricsCache for %s:%s ", component, metric));
return metricsData;
}
// convert heron.protobuf.taskMetrics to dhalion.InstanceMetrics
for (TaskMetric tm : response.getMetricList()) {
String instanceId = tm.getInstanceId();
for (IndividualMetric im : tm.getMetricList()) {
String metricName = im.getName();
// case 1
for (IntervalValue iv : im.getIntervalValuesList()) {
MetricInterval mi = iv.getInterval();
String value = iv.getValue();
Measurement measurement = new Measurement(component, instanceId, metricName, Instant.ofEpochSecond(mi.getStart()), Double.parseDouble(value));
metricsData.add(measurement);
}
// case 2
if (im.hasValue()) {
Measurement measurement = new Measurement(component, instanceId, metricName, startTime, Double.parseDouble(im.getValue()));
metricsData.add(measurement);
}
}
}
return metricsData;
}
Aggregations