use of io.trino.spi.metrics.Metric in project trino by trinodb.
the class TestMetrics method testMergeCount.
@Test
public void testMergeCount() {
Metrics m1 = new Metrics(ImmutableMap.of("a", new LongCount(1), "b", new LongCount(2)));
Metrics m2 = new Metrics(ImmutableMap.of("b", new LongCount(3), "c", new LongCount(4)));
Metrics merged = merge(m1, m2);
Map<String, Metric<?>> expectedMap = ImmutableMap.of("a", new LongCount(1), "b", new LongCount(5), "c", new LongCount(4));
assertThat(merged.getMetrics()).isEqualTo(expectedMap);
}
use of io.trino.spi.metrics.Metric in project trino by trinodb.
the class TextRenderer method printMetrics.
private void printMetrics(StringBuilder output, String label, Function<BasicOperatorStats, Metrics> metricsGetter, PlanNodeStats stats) {
if (!verbose) {
return;
}
Map<String, String> translatedOperatorTypes = translateOperatorTypes(stats.getOperatorTypes());
for (String operator : translatedOperatorTypes.keySet()) {
String translatedOperatorType = translatedOperatorTypes.get(operator);
Metrics metrics = metricsGetter.apply(stats.getOperatorStats().get(operator));
if (metrics.getMetrics().isEmpty()) {
continue;
}
output.append(translatedOperatorType + label).append("\n");
Map<String, Metric<?>> sortedMap = new TreeMap<>(metrics.getMetrics());
sortedMap.forEach((name, metric) -> output.append(format(" '%s' = %s\n", name, metric)));
}
}