use of io.trino.spi.metrics.Metrics in project trino by trinodb.
the class TestMemoryConnectorTest method testCustomMetricsScanFilter.
@Test
// TODO (https://github.com/trinodb/trino/issues/8691) fix the test
@Flaky(issue = "https://github.com/trinodb/trino/issues/8691", match = "ComparisonFailure: expected:<LongCount\\{total=\\[\\d+]}> but was:<(LongCount\\{total=\\[\\d+]}|null)>")
public void testCustomMetricsScanFilter() {
Metrics metrics = collectCustomMetrics("SELECT partkey FROM part WHERE partkey % 1000 > 0");
assertThat(metrics.getMetrics().get("rows")).isEqualTo(new LongCount(PART_COUNT));
assertThat(metrics.getMetrics().get("started")).isEqualTo(metrics.getMetrics().get("finished"));
assertThat(((Count<?>) metrics.getMetrics().get("finished")).getTotal()).isGreaterThan(0);
}
use of io.trino.spi.metrics.Metrics in project trino by trinodb.
the class OperatorContext method getOperatorMetrics.
public static Metrics getOperatorMetrics(Metrics operatorMetrics, long inputPositions) {
TDigest digest = new TDigest();
digest.add(inputPositions);
return operatorMetrics.mergeWith(new Metrics(ImmutableMap.of("Input distribution", new TDigestHistogram(digest))));
}
use of io.trino.spi.metrics.Metrics in project trino by trinodb.
the class WorkProcessorSourceOperatorAdapter method updateOperatorStats.
private void updateOperatorStats() {
long currentPhysicalInputBytes = sourceOperator.getPhysicalInputDataSize().toBytes();
long currentPhysicalInputPositions = sourceOperator.getPhysicalInputPositions();
long currentReadTimeNanos = sourceOperator.getReadTime().roundTo(NANOSECONDS);
long currentInternalNetworkInputBytes = sourceOperator.getInternalNetworkInputDataSize().toBytes();
long currentInternalNetworkPositions = sourceOperator.getInternalNetworkPositions();
long currentInputBytes = sourceOperator.getInputDataSize().toBytes();
long currentInputPositions = sourceOperator.getInputPositions();
long currentDynamicFilterSplitsProcessed = sourceOperator.getDynamicFilterSplitsProcessed();
Metrics currentMetrics = sourceOperator.getMetrics();
Metrics currentConnectorMetrics = sourceOperator.getConnectorMetrics();
if (currentPhysicalInputBytes != previousPhysicalInputBytes || currentPhysicalInputPositions != previousPhysicalInputPositions || currentReadTimeNanos != previousReadTimeNanos) {
operatorContext.recordPhysicalInputWithTiming(currentPhysicalInputBytes - previousPhysicalInputBytes, currentPhysicalInputPositions - previousPhysicalInputPositions, currentReadTimeNanos - previousReadTimeNanos);
previousPhysicalInputBytes = currentPhysicalInputBytes;
previousPhysicalInputPositions = currentPhysicalInputPositions;
previousReadTimeNanos = currentReadTimeNanos;
}
if (currentInternalNetworkInputBytes != previousInternalNetworkInputBytes || currentInternalNetworkPositions != previousInternalNetworkPositions) {
operatorContext.recordNetworkInput(currentInternalNetworkInputBytes - previousInternalNetworkInputBytes, currentInternalNetworkPositions - previousInternalNetworkPositions);
previousInternalNetworkInputBytes = currentInternalNetworkInputBytes;
previousInternalNetworkPositions = currentInternalNetworkPositions;
}
if (currentInputBytes != previousInputBytes || currentInputPositions != previousInputPositions) {
operatorContext.recordProcessedInput(currentInputBytes - previousInputBytes, currentInputPositions - previousInputPositions);
previousInputBytes = currentInputBytes;
previousInputPositions = currentInputPositions;
}
if (currentDynamicFilterSplitsProcessed != previousDynamicFilterSplitsProcessed) {
operatorContext.recordDynamicFilterSplitProcessed(currentDynamicFilterSplitsProcessed - previousDynamicFilterSplitsProcessed);
previousDynamicFilterSplitsProcessed = currentDynamicFilterSplitsProcessed;
}
operatorContext.setLatestMetrics(currentMetrics);
operatorContext.setLatestConnectorMetrics(currentConnectorMetrics);
}
use of io.trino.spi.metrics.Metrics in project trino by trinodb.
the class TestMetrics method testMergeHistogram.
@Test
public void testMergeHistogram() {
TDigest d1 = new TDigest();
d1.add(10.0, 1);
TDigest d2 = new TDigest();
d2.add(5.0, 2);
Metrics m1 = new Metrics(ImmutableMap.of("a", new TDigestHistogram(d1)));
Metrics m2 = new Metrics(ImmutableMap.of("a", new TDigestHistogram(d2)));
TDigestHistogram merged = (TDigestHistogram) merge(m1, m2).getMetrics().get("a");
assertThat(merged.getTotal()).isEqualTo(3L);
assertThat(merged.getPercentile(0)).isEqualTo(5.0);
assertThat(merged.getPercentile(100)).isEqualTo(10.0);
assertThat(merged.toString()).matches("\\{count=3\\.00, p01=5\\.00, p05=5\\.00, p10=5\\.00, p25=5\\.00, p50=7\\.50, p75=10\\.00, p90=10\\.00, p95=10\\.00, p99=10\\.00, min=5\\.00, max=10\\.00\\}");
}
use of io.trino.spi.metrics.Metrics 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);
}
Aggregations