Search in sources :

Example 1 with MetricUpdate

use of org.apache.beam.runners.core.metrics.MetricUpdates.MetricUpdate in project beam by apache.

the class DirectMetricsTest method testPartialScopeMatchingInMetricsQuery.

@SuppressWarnings("unchecked")
@Test
public void testPartialScopeMatchingInMetricsQuery() {
    metrics.updatePhysical(bundle1, MetricUpdates.create(ImmutableList.of(MetricUpdate.create(MetricKey.create("Top1/Outer1/Inner1", NAME1), 5L), MetricUpdate.create(MetricKey.create("Top1/Outer1/Inner2", NAME1), 8L)), ImmutableList.<MetricUpdate<DistributionData>>of(), ImmutableList.<MetricUpdate<GaugeData>>of()));
    metrics.updatePhysical(bundle1, MetricUpdates.create(ImmutableList.of(MetricUpdate.create(MetricKey.create("Top2/Outer1/Inner1", NAME1), 12L), MetricUpdate.create(MetricKey.create("Top1/Outer2/Inner2", NAME1), 18L)), ImmutableList.<MetricUpdate<DistributionData>>of(), ImmutableList.<MetricUpdate<GaugeData>>of()));
    MetricQueryResults results = metrics.queryMetrics(MetricsFilter.builder().addStep("Top1/Outer1").build());
    assertThat(results.counters(), containsInAnyOrder(attemptedMetricsResult("ns1", "name1", "Top1/Outer1/Inner1", 5L), attemptedMetricsResult("ns1", "name1", "Top1/Outer1/Inner2", 8L)));
    results = metrics.queryMetrics(MetricsFilter.builder().addStep("Inner2").build());
    assertThat(results.counters(), containsInAnyOrder(attemptedMetricsResult("ns1", "name1", "Top1/Outer1/Inner2", 8L), attemptedMetricsResult("ns1", "name1", "Top1/Outer2/Inner2", 18L)));
}
Also used : MetricQueryResults(org.apache.beam.sdk.metrics.MetricQueryResults) MetricUpdate(org.apache.beam.runners.core.metrics.MetricUpdates.MetricUpdate) Test(org.junit.Test)

Example 2 with MetricUpdate

use of org.apache.beam.runners.core.metrics.MetricUpdates.MetricUpdate in project beam by apache.

the class DirectMetricsTest method testApplyAttemptedCountersQueryOneNamespace.

@SuppressWarnings("unchecked")
@Test
public void testApplyAttemptedCountersQueryOneNamespace() {
    metrics.updatePhysical(bundle1, MetricUpdates.create(ImmutableList.of(MetricUpdate.create(MetricKey.create("step1", NAME1), 5L), MetricUpdate.create(MetricKey.create("step1", NAME3), 8L)), ImmutableList.<MetricUpdate<DistributionData>>of(), ImmutableList.<MetricUpdate<GaugeData>>of()));
    metrics.updatePhysical(bundle1, MetricUpdates.create(ImmutableList.of(MetricUpdate.create(MetricKey.create("step2", NAME1), 7L), MetricUpdate.create(MetricKey.create("step1", NAME3), 4L)), ImmutableList.<MetricUpdate<DistributionData>>of(), ImmutableList.<MetricUpdate<GaugeData>>of()));
    MetricQueryResults results = metrics.queryMetrics(MetricsFilter.builder().addNameFilter(inNamespace("ns1")).build());
    assertThat(results.counters(), containsInAnyOrder(attemptedMetricsResult("ns1", "name1", "step1", 5L), attemptedMetricsResult("ns1", "name1", "step2", 7L)));
    assertThat(results.counters(), containsInAnyOrder(committedMetricsResult("ns1", "name1", "step1", 0L), committedMetricsResult("ns1", "name1", "step2", 0L)));
}
Also used : MetricQueryResults(org.apache.beam.sdk.metrics.MetricQueryResults) MetricUpdate(org.apache.beam.runners.core.metrics.MetricUpdates.MetricUpdate) Test(org.junit.Test)

Example 3 with MetricUpdate

use of org.apache.beam.runners.core.metrics.MetricUpdates.MetricUpdate in project beam by apache.

the class DirectMetricsTest method testApplyAttemptedQueryCompositeScope.

@SuppressWarnings("unchecked")
@Test
public void testApplyAttemptedQueryCompositeScope() {
    metrics.updatePhysical(bundle1, MetricUpdates.create(ImmutableList.of(MetricUpdate.create(MetricKey.create("Outer1/Inner1", NAME1), 5L), MetricUpdate.create(MetricKey.create("Outer1/Inner2", NAME1), 8L)), ImmutableList.<MetricUpdate<DistributionData>>of(), ImmutableList.<MetricUpdate<GaugeData>>of()));
    metrics.updatePhysical(bundle1, MetricUpdates.create(ImmutableList.of(MetricUpdate.create(MetricKey.create("Outer1/Inner1", NAME1), 12L), MetricUpdate.create(MetricKey.create("Outer2/Inner2", NAME1), 18L)), ImmutableList.<MetricUpdate<DistributionData>>of(), ImmutableList.<MetricUpdate<GaugeData>>of()));
    MetricQueryResults results = metrics.queryMetrics(MetricsFilter.builder().addStep("Outer1").build());
    assertThat(results.counters(), containsInAnyOrder(attemptedMetricsResult("ns1", "name1", "Outer1/Inner1", 12L), attemptedMetricsResult("ns1", "name1", "Outer1/Inner2", 8L)));
    assertThat(results.counters(), containsInAnyOrder(committedMetricsResult("ns1", "name1", "Outer1/Inner1", 0L), committedMetricsResult("ns1", "name1", "Outer1/Inner2", 0L)));
}
Also used : MetricQueryResults(org.apache.beam.sdk.metrics.MetricQueryResults) MetricUpdate(org.apache.beam.runners.core.metrics.MetricUpdates.MetricUpdate) Test(org.junit.Test)

Aggregations

MetricUpdate (org.apache.beam.runners.core.metrics.MetricUpdates.MetricUpdate)3 MetricQueryResults (org.apache.beam.sdk.metrics.MetricQueryResults)3 Test (org.junit.Test)3