Search in sources :

Example 6 with MetricResults

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);
}
Also used : MetricsContainerStepMap.asMetricResults(org.apache.beam.runners.core.metrics.MetricsContainerStepMap.asMetricResults) MetricsContainerStepMap.asAttemptedOnlyMetricResults(org.apache.beam.runners.core.metrics.MetricsContainerStepMap.asAttemptedOnlyMetricResults) MetricResults(org.apache.beam.sdk.metrics.MetricResults) MetricQueryResults(org.apache.beam.sdk.metrics.MetricQueryResults) Test(org.junit.Test)

Example 7 with MetricResults

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;
}
Also used : DistributionResult(org.apache.beam.sdk.metrics.DistributionResult) HashMap(java.util.HashMap) MetricsContainerStepMap.asAttemptedOnlyMetricResults(org.apache.beam.runners.core.metrics.MetricsContainerStepMap.asAttemptedOnlyMetricResults) MetricResults(org.apache.beam.sdk.metrics.MetricResults) MetricQueryResults(org.apache.beam.sdk.metrics.MetricQueryResults) GaugeResult(org.apache.beam.sdk.metrics.GaugeResult)

Aggregations

MetricsContainerStepMap.asAttemptedOnlyMetricResults (org.apache.beam.runners.core.metrics.MetricsContainerStepMap.asAttemptedOnlyMetricResults)7 MetricQueryResults (org.apache.beam.sdk.metrics.MetricQueryResults)7 MetricResults (org.apache.beam.sdk.metrics.MetricResults)7 MetricsContainerStepMap.asMetricResults (org.apache.beam.runners.core.metrics.MetricsContainerStepMap.asMetricResults)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)1 DistributionResult (org.apache.beam.sdk.metrics.DistributionResult)1 GaugeResult (org.apache.beam.sdk.metrics.GaugeResult)1