Search in sources :

Example 1 with Gauge

use of org.apache.beam.sdk.metrics.Gauge in project beam by apache.

the class FlinkMetricContainerTest method testGauge.

@Test
public void testGauge() {
    FlinkMetricContainer.FlinkGauge flinkGauge = new FlinkMetricContainer.FlinkGauge(GaugeResult.empty());
    when(metricGroup.gauge(eq("namespace.name"), anyObject())).thenReturn(flinkGauge);
    MetricsContainer step = container.getMetricsContainer("step");
    MetricName metricName = MetricName.named("namespace", "name");
    Gauge gauge = step.getGauge(metricName);
    assertThat(flinkGauge.getValue(), is(-1L));
    // first set will install the mocked gauge
    container.updateMetrics("step");
    gauge.set(1);
    gauge.set(42);
    container.updateMetrics("step");
    assertThat(flinkGauge.getValue(), is(42L));
}
Also used : MetricName(org.apache.beam.sdk.metrics.MetricName) MonitoringInfoMetricName(org.apache.beam.runners.core.metrics.MonitoringInfoMetricName) MetricsContainer(org.apache.beam.sdk.metrics.MetricsContainer) FlinkDistributionGauge(org.apache.beam.runners.flink.metrics.FlinkMetricContainer.FlinkDistributionGauge) Gauge(org.apache.beam.sdk.metrics.Gauge) Test(org.junit.Test)

Aggregations

MonitoringInfoMetricName (org.apache.beam.runners.core.metrics.MonitoringInfoMetricName)1 FlinkDistributionGauge (org.apache.beam.runners.flink.metrics.FlinkMetricContainer.FlinkDistributionGauge)1 Gauge (org.apache.beam.sdk.metrics.Gauge)1 MetricName (org.apache.beam.sdk.metrics.MetricName)1 MetricsContainer (org.apache.beam.sdk.metrics.MetricsContainer)1 Test (org.junit.Test)1