use of org.apache.beam.sdk.metrics.MetricKey in project flink by apache.
the class FlinkMetricContainerTest method testGetFlinkMetricIdentifierString.
@Test
public void testGetFlinkMetricIdentifierString() {
MetricKey key = MetricKey.create("step", MetricName.named(DEFAULT_NAMESPACE, "name"));
assertThat(FlinkMetricContainer.getFlinkMetricIdentifierString(key), is("key.value.name"));
}
use of org.apache.beam.sdk.metrics.MetricKey in project beam by apache.
the class SparkBeamMetric method renderName.
@VisibleForTesting
String renderName(MetricResult<?> metricResult) {
MetricKey key = metricResult.getKey();
MetricName name = key.metricName();
String step = key.stepName();
ArrayList<String> pieces = new ArrayList<>();
if (step != null) {
step = step.replaceAll(ILLEGAL_CHARACTERS, "_");
if (step.endsWith("_")) {
step = step.substring(0, step.length() - 1);
}
pieces.add(step);
}
pieces.addAll(ImmutableList.of(name.getNamespace(), name.getName()).stream().map(str -> str.replaceAll(ILLEGAL_CHARACTERS, "_")).collect(toList()));
return String.join(".", pieces);
}
use of org.apache.beam.sdk.metrics.MetricKey in project beam by apache.
the class SparkBeamMetric method renderName.
@VisibleForTesting
static String renderName(MetricResult<?> metricResult) {
MetricKey key = metricResult.getKey();
MetricName name = key.metricName();
String step = key.stepName();
ArrayList<String> pieces = new ArrayList<>();
if (step != null) {
step = step.replaceAll(ILLEGAL_CHARACTERS, "_");
if (step.endsWith("_")) {
step = step.substring(0, step.length() - 1);
}
pieces.add(step);
}
pieces.addAll(ImmutableList.of(name.getNamespace(), name.getName()).stream().map(str -> str.replaceAll(ILLEGAL_CHARACTERS, "_")).collect(toList()));
return String.join(".", pieces);
}
use of org.apache.beam.sdk.metrics.MetricKey in project beam by apache.
the class CustomMetricQueryResults method makeResults.
private <T> List<MetricResult<T>> makeResults(String step, String name, T committed, T attempted) {
MetricName metricName = MetricName.named(NAMESPACE, name);
MetricKey key = MetricKey.create(step, metricName);
return Collections.singletonList(isCommittedSupported ? MetricResult.create(key, committed, attempted) : MetricResult.attempted(key, attempted));
}
use of org.apache.beam.sdk.metrics.MetricKey in project beam by apache.
the class MetricsContainerStepMap method mergeAttemptedResults.
@SuppressWarnings("ConstantConditions")
private static <T> void mergeAttemptedResults(Map<MetricKey, MetricResult<T>> metricResultMap, Iterable<MetricUpdate<T>> updates, BiFunction<T, T, T> combine) {
for (MetricUpdate<T> metricUpdate : updates) {
MetricKey key = metricUpdate.getKey();
metricResultMap.compute(key, (k, current) -> {
if (current == null) {
return MetricResult.attempted(key, metricUpdate.getUpdate());
} else {
return current.addAttempted(metricUpdate.getUpdate(), combine);
}
});
}
}
Aggregations