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));
}
Aggregations