use of org.apache.beam.sdk.metrics.MetricKey in project beam by apache.
the class JetMetricsContainer method extractUpdates.
private <UpdateT, CellT extends AbstractMetric<UpdateT>> ImmutableList<MetricUpdates.MetricUpdate<UpdateT>> extractUpdates(Map<MetricName, CellT> cells) {
ImmutableList.Builder<MetricUpdates.MetricUpdate<UpdateT>> updates = ImmutableList.builder();
for (CellT cell : cells.values()) {
UpdateT value = cell.getValue();
if (value != null) {
MetricKey key = MetricKey.create(stepName, cell.getName());
MetricUpdates.MetricUpdate<UpdateT> update = MetricUpdates.MetricUpdate.create(key, value);
updates.add(update);
}
}
return updates.build();
}
use of org.apache.beam.sdk.metrics.MetricKey in project beam by apache.
the class PortableMetrics method convertDistributionMonitoringInfoToDistribution.
private static MetricResult<DistributionResult> convertDistributionMonitoringInfoToDistribution(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)));
DistributionData data = decodeInt64Distribution(monitoringInfo.getPayload());
DistributionResult result = DistributionResult.create(data.sum(), data.count(), data.min(), data.max());
return MetricResult.create(key, false, result);
}
use of org.apache.beam.sdk.metrics.MetricKey in project beam by apache.
the class PortableMetrics method convertCounterMonitoringInfoToCounter.
private static MetricResult<Long> convertCounterMonitoringInfoToCounter(MetricsApi.MonitoringInfo counterMonInfo) {
Map<String, String> labelsMap = counterMonInfo.getLabelsMap();
MetricKey key = MetricKey.create(labelsMap.get(STEP_NAME_LABEL), MetricName.named(labelsMap.get(NAMESPACE_LABEL), labelsMap.get(METRIC_NAME_LABEL)));
return MetricResult.create(key, false, decodeInt64Counter(counterMonInfo.getPayload()));
}
use of org.apache.beam.sdk.metrics.MetricKey in project flink by apache.
the class FlinkMetricContainerTest method testGetNameSpaceArray.
@Test
public void testGetNameSpaceArray() {
String json = "[\"key\", \"value\", \"MetricGroupType.key\", \"MetricGroupType.value\"]";
MetricKey key = MetricKey.create("step", MetricName.named(json, "name"));
assertThat(FlinkMetricContainer.getNameSpaceArray(key), is(DEFAULT_SCOPE_COMPONENTS));
}
use of org.apache.beam.sdk.metrics.MetricKey in project flink by apache.
the class FlinkMetricContainerTest method testRegisterMetricGroup.
@Test
public void testRegisterMetricGroup() {
MetricKey key = MetricKey.create("step", MetricName.named(DEFAULT_NAMESPACE, "name"));
MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
GenericMetricGroup root = new GenericMetricGroup(registry, new MetricGroupTest.DummyAbstractMetricGroup(registry), "root");
MetricGroup metricGroup = FlinkMetricContainer.registerMetricGroup(key, root);
assertThat(metricGroup.getScopeComponents(), is(Arrays.asList("root", "key", "value").toArray()));
}
Aggregations