Search in sources :

Example 16 with CounterStructuredNameAndMetadata

use of com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata in project beam by apache.

the class StreamingStepMetricsContainerTest method testCounterUpdateExtraction.

@Test
public void testCounterUpdateExtraction() {
    c1.getCounter(name1).inc(5);
    c2.getCounter(name1).inc(8);
    c2.getCounter(name2).inc(12);
    Iterable<CounterUpdate> updates = StreamingStepMetricsContainer.extractMetricUpdates(registry);
    assertThat(updates, containsInAnyOrder(new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setName(new CounterStructuredName().setOrigin(Origin.USER.toString()).setOriginNamespace("ns").setName("name1").setOriginalStepName("s1")).setMetadata(new CounterMetadata().setKind(Kind.SUM.toString()))).setCumulative(false).setInteger(longToSplitInt(5)), new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setName(new CounterStructuredName().setOrigin(Origin.USER.toString()).setOriginNamespace("ns").setName("name1").setOriginalStepName("s2")).setMetadata(new CounterMetadata().setKind(Kind.SUM.toString()))).setCumulative(false).setInteger(longToSplitInt(8)), new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setName(new CounterStructuredName().setOrigin(Origin.USER.toString()).setOriginNamespace("ns").setName("name2").setOriginalStepName("s2")).setMetadata(new CounterMetadata().setKind(Kind.SUM.toString()))).setCumulative(false).setInteger(longToSplitInt(12))));
    c2.getCounter(name1).inc(7);
    updates = StreamingStepMetricsContainer.extractMetricUpdates(registry);
    assertThat(updates, containsInAnyOrder(new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setName(new CounterStructuredName().setOrigin(Origin.USER.toString()).setOriginNamespace("ns").setName("name1").setOriginalStepName("s2")).setMetadata(new CounterMetadata().setKind(Kind.SUM.toString()))).setCumulative(false).setInteger(longToSplitInt(7))));
}
Also used : CounterMetadata(com.google.api.services.dataflow.model.CounterMetadata) CounterStructuredName(com.google.api.services.dataflow.model.CounterStructuredName) CounterStructuredNameAndMetadata(com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata) CounterUpdate(com.google.api.services.dataflow.model.CounterUpdate) Test(org.junit.Test)

Example 17 with CounterStructuredNameAndMetadata

use of com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata in project beam by apache.

the class CounterUpdateAggregatorsTest method testAggregateDistribution.

@Test
public void testAggregateDistribution() {
    List<CounterUpdate> distributionUpdates = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        distributionUpdates.add(new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setMetadata(new CounterMetadata().setKind(Kind.DISTRIBUTION.toString()))).setDistribution(new DistributionUpdate().setSum(longToSplitInt((long) i)).setMax(longToSplitInt((long) i)).setMin(longToSplitInt((long) i)).setCount(longToSplitInt((long) 1))));
    }
    List<CounterUpdate> aggregated = CounterUpdateAggregators.aggregate(distributionUpdates);
    assertEquals(1, aggregated.size());
    CounterUpdate combined = aggregated.get(0);
    assertEquals(45L, splitIntToLong(combined.getDistribution().getSum()));
    assertEquals(10L, splitIntToLong(combined.getDistribution().getCount()));
    assertEquals(9L, splitIntToLong(combined.getDistribution().getMax()));
    assertEquals(0L, splitIntToLong(combined.getDistribution().getMin()));
}
Also used : CounterMetadata(com.google.api.services.dataflow.model.CounterMetadata) ArrayList(java.util.ArrayList) DistributionUpdate(com.google.api.services.dataflow.model.DistributionUpdate) CounterStructuredNameAndMetadata(com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata) CounterUpdate(com.google.api.services.dataflow.model.CounterUpdate) Test(org.junit.Test)

Example 18 with CounterStructuredNameAndMetadata

use of com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata in project beam by apache.

the class MeanCounterUpdateAggregatorTest method setUp.

@Before
public void setUp() {
    counterUpdates = new ArrayList<>();
    aggregator = new MeanCounterUpdateAggregator();
    for (int i = 0; i < 10; i++) {
        counterUpdates.add(new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setMetadata(new CounterMetadata().setKind(Kind.MEAN.toString()))).setIntegerMean(new IntegerMean().setSum(longToSplitInt((long) i)).setCount(longToSplitInt(1L))));
    }
}
Also used : CounterMetadata(com.google.api.services.dataflow.model.CounterMetadata) IntegerMean(com.google.api.services.dataflow.model.IntegerMean) CounterStructuredNameAndMetadata(com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata) CounterUpdate(com.google.api.services.dataflow.model.CounterUpdate) Before(org.junit.Before)

Example 19 with CounterStructuredNameAndMetadata

use of com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata in project beam by apache.

the class CounterUpdateAggregatorsTest method testAggregateSum.

@Test
public void testAggregateSum() {
    List<CounterUpdate> sumUpdates = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        sumUpdates.add(new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setMetadata(new CounterMetadata().setKind(Kind.SUM.toString()))).setInteger(longToSplitInt((long) i)));
    }
    List<CounterUpdate> aggregated = CounterUpdateAggregators.aggregate(sumUpdates);
    assertEquals(1, aggregated.size());
    CounterUpdate combined = aggregated.get(0);
    assertEquals(45L, splitIntToLong(combined.getInteger()));
}
Also used : CounterMetadata(com.google.api.services.dataflow.model.CounterMetadata) ArrayList(java.util.ArrayList) CounterStructuredNameAndMetadata(com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata) CounterUpdate(com.google.api.services.dataflow.model.CounterUpdate) Test(org.junit.Test)

Example 20 with CounterStructuredNameAndMetadata

use of com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata in project beam by apache.

the class SumCounterUpdateAggregatorTest method setUp.

@Before
public void setUp() {
    counterUpdates = new ArrayList<>();
    aggregator = new SumCounterUpdateAggregator();
    for (int i = 0; i < 10; i++) {
        counterUpdates.add(new CounterUpdate().setStructuredNameAndMetadata(new CounterStructuredNameAndMetadata().setMetadata(new CounterMetadata().setKind(Kind.SUM.toString()))).setInteger(longToSplitInt((long) i)));
    }
}
Also used : CounterMetadata(com.google.api.services.dataflow.model.CounterMetadata) CounterStructuredNameAndMetadata(com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata) CounterUpdate(com.google.api.services.dataflow.model.CounterUpdate) Before(org.junit.Before)

Aggregations

CounterStructuredNameAndMetadata (com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata)20 CounterMetadata (com.google.api.services.dataflow.model.CounterMetadata)18 CounterUpdate (com.google.api.services.dataflow.model.CounterUpdate)18 CounterStructuredName (com.google.api.services.dataflow.model.CounterStructuredName)13 Test (org.junit.Test)10 DistributionUpdate (com.google.api.services.dataflow.model.DistributionUpdate)6 ArrayList (java.util.ArrayList)4 DataflowStepContext (org.apache.beam.runners.dataflow.worker.DataflowExecutionContext.DataflowStepContext)3 Nullable (org.checkerframework.checker.nullness.qual.Nullable)3 Before (org.junit.Before)3 IntegerMean (com.google.api.services.dataflow.model.IntegerMean)2 WorkItemStatus (com.google.api.services.dataflow.model.WorkItemStatus)2 Distribution (org.apache.beam.sdk.metrics.Distribution)2 NameAndKind (com.google.api.services.dataflow.model.NameAndKind)1 Source (com.google.api.services.dataflow.model.Source)1 SplitInt64 (com.google.api.services.dataflow.model.SplitInt64)1 Closeable (java.io.Closeable)1 CounterCell (org.apache.beam.runners.core.metrics.CounterCell)1 DistributionData (org.apache.beam.runners.core.metrics.DistributionData)1 MetricsContainerImpl (org.apache.beam.runners.core.metrics.MetricsContainerImpl)1