use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class MetricsCacheMetricsProvider method parse.
@VisibleForTesting
@SuppressWarnings("unchecked")
Map<String, InstanceMetrics> parse(TopologyMaster.MetricResponse response, String component, String metric, Instant startTime) {
Map<String, InstanceMetrics> metricsData = new HashMap<>();
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();
InstanceMetrics instanceMetrics = new InstanceMetrics(instanceId);
for (IndividualMetric im : tm.getMetricList()) {
String metricName = im.getName();
Map<Instant, Double> values = new HashMap<>();
// case 1
for (IntervalValue iv : im.getIntervalValuesList()) {
MetricInterval mi = iv.getInterval();
String value = iv.getValue();
values.put(Instant.ofEpochSecond(mi.getStart()), Double.parseDouble(value));
}
// case 2
if (im.hasValue()) {
values.put(startTime, Double.parseDouble(im.getValue()));
}
if (!values.isEmpty()) {
instanceMetrics.addMetric(metricName, values);
}
}
metricsData.put(instanceId, instanceMetrics);
}
return metricsData;
}
use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class TestUtils method addInstanceMetric.
private static void addInstanceMetric(ComponentMetrics metrics, int i, double val, String metric) {
InstanceMetrics instanceMetric = new InstanceMetrics("container_1_bolt_" + i, metric, val);
metrics.addInstanceMetric(instanceMetric);
}
use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class ComponentMetricsHelper method computeMinMaxStats.
public MetricsStats computeMinMaxStats(String metric) {
double metricMax = 0;
double metricMin = Double.MAX_VALUE;
for (InstanceMetrics instance : componentMetrics.getMetrics().values()) {
Double metricValue = instance.getMetricValueSum(metric);
if (metricValue == null) {
continue;
}
metricMax = metricMax < metricValue ? metricValue : metricMax;
metricMin = metricMin > metricValue ? metricValue : metricMin;
}
return new MetricsStats(metricMin, metricMax);
}
use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class ComponentMetricsHelper method computeBpStats.
public void computeBpStats() {
for (InstanceMetrics instanceMetrics : componentMetrics.getMetrics().values()) {
Double bpValue = instanceMetrics.getMetricValueSum(METRIC_BACK_PRESSURE.text());
if (bpValue != null && bpValue > 0) {
boltsWithBackpressure.add(instanceMetrics);
totalBackpressure += bpValue;
}
}
}
use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.
the class ComponentMetricsHelper method computeBufferSizeTrend.
public void computeBufferSizeTrend() {
for (InstanceMetrics instanceMetrics : componentMetrics.getMetrics().values()) {
Map<Instant, Double> bufferMetrics = instanceMetrics.getMetrics().get(METRIC_BUFFER_SIZE.text());
if (bufferMetrics == null || bufferMetrics.size() < 3) {
// missing of insufficient data for creating a trend line
continue;
}
SimpleRegression simpleRegression = new SimpleRegression(true);
for (Instant timestamp : bufferMetrics.keySet()) {
simpleRegression.addData(timestamp.getEpochSecond(), bufferMetrics.get(timestamp));
}
double slope = simpleRegression.getSlope();
instanceMetrics.addMetric(METRIC_WAIT_Q_GROWTH_RATE.text(), slope);
if (maxBufferChangeRate < slope) {
maxBufferChangeRate = slope;
}
}
}
Aggregations