Search in sources :

Example 11 with MetricKey

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

the class FlinkMetricContainerTest method testMetricNameGeneration.

@Test
public void testMetricNameGeneration() {
    MetricKey key = MetricKey.create("step", MetricName.named("namespace", "name"));
    String name = getFlinkMetricNameString(key);
    assertThat(name, is("namespace.name"));
}
Also used : MetricKey(org.apache.beam.sdk.metrics.MetricKey) FlinkMetricContainer.getFlinkMetricNameString(org.apache.beam.runners.flink.metrics.FlinkMetricContainer.getFlinkMetricNameString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 12 with MetricKey

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

the class PortableMetrics method convertGaugeMonitoringInfoToGauge.

private static MetricResult<GaugeResult> convertGaugeMonitoringInfoToGauge(MetricsApi.MonitoringInfo monitoringInfo) {
    Map<String, String> labelsMap = monitoringInfo.getLabelsMap();
    MetricKey key = MetricKey.create(labelsMap.get(STEP_NAME_LABEL), MetricName.named(labelsMap.get(NAMESPACE_LABEL), labelsMap.get(METRIC_NAME_LABEL)));
    GaugeData data = decodeInt64Gauge(monitoringInfo.getPayload());
    GaugeResult result = GaugeResult.create(data.value(), data.timestamp());
    return MetricResult.create(key, false, result);
}
Also used : MetricKey(org.apache.beam.sdk.metrics.MetricKey) GaugeData(org.apache.beam.runners.core.metrics.GaugeData) GaugeResult(org.apache.beam.sdk.metrics.GaugeResult)

Aggregations

MetricKey (org.apache.beam.sdk.metrics.MetricKey)12 Test (org.junit.Test)4 MetricName (org.apache.beam.sdk.metrics.MetricName)3 MetricGroupTest (org.apache.flink.runtime.metrics.groups.MetricGroupTest)3 ArrayList (java.util.ArrayList)2 VisibleForTesting (org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting)2 DistributionData (org.apache.beam.runners.core.metrics.DistributionData)1 GaugeData (org.apache.beam.runners.core.metrics.GaugeData)1 MetricUpdates (org.apache.beam.runners.core.metrics.MetricUpdates)1 FlinkMetricContainer.getFlinkMetricNameString (org.apache.beam.runners.flink.metrics.FlinkMetricContainer.getFlinkMetricNameString)1 DistributionResult (org.apache.beam.sdk.metrics.DistributionResult)1 GaugeResult (org.apache.beam.sdk.metrics.GaugeResult)1 ImmutableList (org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList)1 MetricGroup (org.apache.flink.metrics.MetricGroup)1 OperatorMetricGroup (org.apache.flink.metrics.groups.OperatorMetricGroup)1 MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)1 NoOpMetricRegistry (org.apache.flink.runtime.metrics.NoOpMetricRegistry)1 GenericMetricGroup (org.apache.flink.runtime.metrics.groups.GenericMetricGroup)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1