use of org.apache.beam.sdk.metrics.MetricResults in project beam by apache.
the class MetricsContainerStepMapTest method testDistributionCommittedUnsupportedInAttemptedAccumulatedMetricResults.
@Test
public void testDistributionCommittedUnsupportedInAttemptedAccumulatedMetricResults() {
MetricsContainerStepMap attemptedMetrics = new MetricsContainerStepMap();
attemptedMetrics.update(STEP1, metricsContainer);
MetricResults metricResults = asAttemptedOnlyMetricResults(attemptedMetrics);
MetricQueryResults step1res = metricResults.queryMetrics(MetricsFilter.builder().addStep(STEP1).build());
thrown.expect(UnsupportedOperationException.class);
thrown.expectMessage("This runner does not currently support committed metrics results.");
assertDistribution(DISTRIBUTION_NAME, step1res, STEP1, DistributionResult.ZERO, true);
}
use of org.apache.beam.sdk.metrics.MetricResults in project beam by apache.
the class SparkBeamMetric method renderAll.
Map<String, ?> renderAll() {
Map<String, Object> metrics = new HashMap<>();
MetricResults metricResults = asAttemptedOnlyMetricResults(MetricsAccumulator.getInstance().value());
MetricQueryResults metricQueryResults = metricResults.queryMetrics(MetricsFilter.builder().build());
for (MetricResult<Long> metricResult : metricQueryResults.counters()) {
metrics.put(renderName(metricResult), metricResult.attempted());
}
for (MetricResult<DistributionResult> metricResult : metricQueryResults.distributions()) {
DistributionResult result = metricResult.attempted();
metrics.put(renderName(metricResult) + ".count", result.count());
metrics.put(renderName(metricResult) + ".sum", result.sum());
metrics.put(renderName(metricResult) + ".min", result.min());
metrics.put(renderName(metricResult) + ".max", result.max());
metrics.put(renderName(metricResult) + ".mean", result.mean());
}
for (MetricResult<GaugeResult> metricResult : metricQueryResults.gauges()) {
metrics.put(renderName(metricResult), metricResult.attempted().value());
}
return metrics;
}
Aggregations