use of org.apache.beam.sdk.metrics.MetricQueryResults in project beam by apache.
the class MetricsContainerStepMapTest method testAttemptedAndCommittedAccumulatedMetricResults.
@Test
public void testAttemptedAndCommittedAccumulatedMetricResults() {
MetricsContainerStepMap attemptedMetrics = new MetricsContainerStepMap();
attemptedMetrics.update(STEP1, metricsContainer);
attemptedMetrics.update(STEP1, metricsContainer);
attemptedMetrics.update(STEP2, metricsContainer);
attemptedMetrics.update(STEP2, metricsContainer);
attemptedMetrics.update(STEP2, metricsContainer);
MetricsContainerStepMap committedMetrics = new MetricsContainerStepMap();
committedMetrics.update(STEP1, metricsContainer);
committedMetrics.update(STEP2, metricsContainer);
committedMetrics.update(STEP2, metricsContainer);
MetricResults metricResults = asMetricResults(attemptedMetrics, committedMetrics);
MetricQueryResults step1res = metricResults.queryMetrics(MetricsFilter.builder().addStep(STEP1).build());
assertIterableSize(step1res.counters(), 1);
assertIterableSize(step1res.distributions(), 1);
assertIterableSize(step1res.gauges(), 1);
assertCounter(COUNTER_NAME, step1res, STEP1, VALUE * 2, false);
assertDistribution(DISTRIBUTION_NAME, step1res, STEP1, DistributionResult.create(VALUE * 6, 4, VALUE, VALUE * 2), false);
assertGauge(GAUGE_NAME, step1res, STEP1, GaugeResult.create(VALUE, Instant.now()), false);
assertCounter(COUNTER_NAME, step1res, STEP1, VALUE, true);
assertDistribution(DISTRIBUTION_NAME, step1res, STEP1, DistributionResult.create(VALUE * 3, 2, VALUE, VALUE * 2), true);
assertGauge(GAUGE_NAME, step1res, STEP1, GaugeResult.create(VALUE, Instant.now()), true);
MetricQueryResults step2res = metricResults.queryMetrics(MetricsFilter.builder().addStep(STEP2).build());
assertIterableSize(step2res.counters(), 1);
assertIterableSize(step2res.distributions(), 1);
assertIterableSize(step2res.gauges(), 1);
assertCounter(COUNTER_NAME, step2res, STEP2, VALUE * 3, false);
assertDistribution(DISTRIBUTION_NAME, step2res, STEP2, DistributionResult.create(VALUE * 9, 6, VALUE, VALUE * 2), false);
assertGauge(GAUGE_NAME, step2res, STEP2, GaugeResult.create(VALUE, Instant.now()), false);
assertCounter(COUNTER_NAME, step2res, STEP2, VALUE * 2, true);
assertDistribution(DISTRIBUTION_NAME, step2res, STEP2, DistributionResult.create(VALUE * 6, 4, VALUE, VALUE * 2), true);
assertGauge(GAUGE_NAME, step2res, STEP2, GaugeResult.create(VALUE, Instant.now()), true);
MetricQueryResults allres = metricResults.queryMetrics(MetricsFilter.builder().build());
assertIterableSize(allres.counters(), 2);
assertIterableSize(allres.distributions(), 2);
assertIterableSize(allres.gauges(), 2);
}
use of org.apache.beam.sdk.metrics.MetricQueryResults in project beam by apache.
the class MetricsContainerStepMapTest method testAttemptedAccumulatedMetricResults.
@Test
public void testAttemptedAccumulatedMetricResults() {
MetricsContainerStepMap attemptedMetrics = new MetricsContainerStepMap();
attemptedMetrics.update(STEP1, metricsContainer);
attemptedMetrics.update(STEP2, metricsContainer);
attemptedMetrics.update(STEP2, metricsContainer);
MetricResults metricResults = asAttemptedOnlyMetricResults(attemptedMetrics);
MetricQueryResults step1res = metricResults.queryMetrics(MetricsFilter.builder().addStep(STEP1).build());
assertIterableSize(step1res.counters(), 1);
assertIterableSize(step1res.distributions(), 1);
assertIterableSize(step1res.gauges(), 1);
assertCounter(COUNTER_NAME, step1res, STEP1, VALUE, false);
assertDistribution(DISTRIBUTION_NAME, step1res, STEP1, DistributionResult.create(VALUE * 3, 2, VALUE, VALUE * 2), false);
assertGauge(GAUGE_NAME, step1res, STEP1, GaugeResult.create(VALUE, Instant.now()), false);
MetricQueryResults step2res = metricResults.queryMetrics(MetricsFilter.builder().addStep(STEP2).build());
assertIterableSize(step2res.counters(), 1);
assertIterableSize(step2res.distributions(), 1);
assertIterableSize(step2res.gauges(), 1);
assertCounter(COUNTER_NAME, step2res, STEP2, VALUE * 2, false);
assertDistribution(DISTRIBUTION_NAME, step2res, STEP2, DistributionResult.create(VALUE * 6, 4, VALUE, VALUE * 2), false);
assertGauge(GAUGE_NAME, step2res, STEP2, GaugeResult.create(VALUE, Instant.now()), false);
MetricQueryResults allres = metricResults.queryMetrics(MetricsFilter.builder().build());
assertIterableSize(allres.counters(), 2);
assertIterableSize(allres.distributions(), 2);
assertIterableSize(allres.gauges(), 2);
}
use of org.apache.beam.sdk.metrics.MetricQueryResults in project beam by apache.
the class MetricsContainerStepMapTest method testGaugeCommittedUnsupportedInAttemptedAccumulatedMetricResults.
@Test
public void testGaugeCommittedUnsupportedInAttemptedAccumulatedMetricResults() {
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.");
assertGauge(GAUGE_NAME, step1res, STEP1, GaugeResult.empty(), true);
}
use of org.apache.beam.sdk.metrics.MetricQueryResults in project beam by apache.
the class MetricsContainerStepMapTest method testCounterCommittedUnsupportedInAttemptedAccumulatedMetricResults.
@Test
public void testCounterCommittedUnsupportedInAttemptedAccumulatedMetricResults() {
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.");
assertCounter(COUNTER_NAME, step1res, STEP1, VALUE, true);
}
use of org.apache.beam.sdk.metrics.MetricQueryResults in project beam by apache.
the class FlinkMetricContainer method updateMetrics.
void updateMetrics() {
MetricResults metricResults = asAttemptedOnlyMetricResults(metricsAccumulator.getLocalValue());
MetricQueryResults metricQueryResults = metricResults.queryMetrics(MetricsFilter.builder().build());
updateCounters(metricQueryResults.counters());
updateDistributions(metricQueryResults.distributions());
updateGauge(metricQueryResults.gauges());
}
Aggregations