From 3822ebaab689fecbe253e6c5e3c2c4713f8e09e0 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Tue, 8 Aug 2023 11:41:14 +0100 Subject: [PATCH 1/2] POC- Expose Pinot metrics --- .../io/trino/plugin/pinot/PinotBrokerPageSource.java | 5 +++++ .../java/io/trino/plugin/pinot/client/PinotClient.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java index 798fb2af43a8..7824550338e4 100644 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java @@ -154,6 +154,11 @@ public long getMemoryUsage() return 0; } + @Override + public Metrics getMetrics() { + return new Metrics(pinotClient.getMetrics(session, query)); + } + @Override public void close() {} } diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java index 4f33a06d116e..7eb6bd27387e 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java @@ -588,6 +588,15 @@ public Iterator createResultIterator(ConnectorSession session, return fromResultTable(response, columnHandles, query.getGroupByClauses()); } + public Map> getMetrics(ConnectorSession session, PinotQueryInfo query) + { + BrokerResponseNative response = submitBrokerQueryJson(session, query); + Map> metrics = ImmutableMap.of( + "numDocsScanned", new LongCount(response.getNumDocsScanned()) + ); + return metrics; + } + @VisibleForTesting public static ResultsIterator fromResultTable(BrokerResponseNative brokerResponse, List columnHandles, int groupByClauses) { From ed320d1c4e80add377ec08cfe624d0043a4e239f Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Tue, 8 Aug 2023 11:45:25 +0100 Subject: [PATCH 2/2] other metrics --- .../main/java/io/trino/plugin/pinot/client/PinotClient.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java index 7eb6bd27387e..2dbc58a879b7 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java @@ -592,7 +592,11 @@ public Map> getMetrics(ConnectorSession session, PinotQueryInf { BrokerResponseNative response = submitBrokerQueryJson(session, query); Map> metrics = ImmutableMap.of( - "numDocsScanned", new LongCount(response.getNumDocsScanned()) + "numDocsScanned", new LongCount(response.getNumDocsScanned()), + "numSegmentsQueried", new LongCount(response.getNumSegmentsQueried()), + "totalDocs", new LongCount(response.getTotalDocs()), + "numSegmentsProcessed", new LongCount(response.getNumSegmentsProcessed()), + "numSegmentsMatched", new LongCount(response.getNumSegmentsMatched()), ); return metrics; }