|
41 | 41 | import javax.annotation.concurrent.ThreadSafe; |
42 | 42 | import org.apache.commons.collections.CollectionUtils; |
43 | 43 | import org.apache.commons.lang3.StringUtils; |
44 | | -import org.apache.pinot.broker.api.RequestStatistics; |
45 | 44 | import org.apache.pinot.broker.api.RequesterIdentity; |
46 | 45 | import org.apache.pinot.broker.broker.AccessControlFactory; |
47 | 46 | import org.apache.pinot.broker.queryquota.QueryQuotaManager; |
|
90 | 89 | import org.apache.pinot.spi.data.Schema; |
91 | 90 | import org.apache.pinot.spi.env.PinotConfiguration; |
92 | 91 | import org.apache.pinot.spi.exception.BadQueryRequestException; |
| 92 | +import org.apache.pinot.spi.trace.RequestStatistics; |
93 | 93 | import org.apache.pinot.spi.utils.BytesUtils; |
94 | 94 | import org.apache.pinot.spi.utils.CommonConstants; |
95 | 95 | import org.apache.pinot.spi.utils.CommonConstants.Broker; |
@@ -207,7 +207,7 @@ private BrokerResponseNative handleSQLRequest(long requestId, String query, Json |
207 | 207 | @Nullable RequesterIdentity requesterIdentity, RequestStatistics requestStatistics) |
208 | 208 | throws Exception { |
209 | 209 | LOGGER.debug("SQL query for request {}: {}", requestId, query); |
210 | | - requestStatistics.setPql(query); |
| 210 | + requestStatistics.setQuery(query); |
211 | 211 |
|
212 | 212 | // Compile the request |
213 | 213 | long compilationStartTimeNs = System.nanoTime(); |
@@ -562,7 +562,7 @@ private BrokerResponseNative handleSQLRequest(long requestId, String query, Json |
562 | 562 | long totalTimeMs = TimeUnit.NANOSECONDS.toMillis(executionEndTimeNs - compilationStartTimeNs); |
563 | 563 | brokerResponse.setTimeUsedMs(totalTimeMs); |
564 | 564 | requestStatistics.setQueryProcessingTime(totalTimeMs); |
565 | | - requestStatistics.setStatistics(brokerResponse); |
| 565 | + augmentStatistics(requestStatistics, brokerResponse); |
566 | 566 |
|
567 | 567 | logBrokerResponse(requestId, query, requestStatistics, brokerRequest, numUnavailableSegments, serverStats, |
568 | 568 | brokerResponse, totalTimeMs); |
@@ -706,7 +706,7 @@ private BrokerResponseNative handlePQLRequest(long requestId, String query, Json |
706 | 706 | @Nullable RequesterIdentity requesterIdentity, RequestStatistics requestStatistics) |
707 | 707 | throws Exception { |
708 | 708 | LOGGER.debug("PQL query for request {}: {}", requestId, query); |
709 | | - requestStatistics.setPql(query); |
| 709 | + requestStatistics.setQuery(query); |
710 | 710 |
|
711 | 711 | // Compile the request |
712 | 712 | long compilationStartTimeNs = System.nanoTime(); |
@@ -947,7 +947,7 @@ private BrokerResponseNative handlePQLRequest(long requestId, String query, Json |
947 | 947 | long totalTimeMs = TimeUnit.NANOSECONDS.toMillis(executionEndTimeNs - compilationStartTimeNs); |
948 | 948 | brokerResponse.setTimeUsedMs(totalTimeMs); |
949 | 949 | requestStatistics.setQueryProcessingTime(totalTimeMs); |
950 | | - requestStatistics.setStatistics(brokerResponse); |
| 950 | + augmentStatistics(requestStatistics, brokerResponse); |
951 | 951 |
|
952 | 952 | LOGGER.debug("Broker Response: {}", brokerResponse); |
953 | 953 |
|
@@ -1570,7 +1570,7 @@ private BrokerResponseNative processLiteralOnlyQuery(PinotQuery pinotQuery, long |
1570 | 1570 | long totalTimeMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - compilationStartTimeNs); |
1571 | 1571 | brokerResponse.setTimeUsedMs(totalTimeMs); |
1572 | 1572 | requestStatistics.setQueryProcessingTime(totalTimeMs); |
1573 | | - requestStatistics.setStatistics(brokerResponse); |
| 1573 | + augmentStatistics(requestStatistics, brokerResponse); |
1574 | 1574 | return brokerResponse; |
1575 | 1575 | } |
1576 | 1576 |
|
@@ -2276,6 +2276,30 @@ protected abstract BrokerResponseNative processBrokerRequest(long requestId, Bro |
2276 | 2276 | List<String>> realtimeRoutingTable, long timeoutMs, ServerStats serverStats, RequestStatistics requestStatistics) |
2277 | 2277 | throws Exception; |
2278 | 2278 |
|
| 2279 | + private static void augmentStatistics(RequestStatistics statistics, BrokerResponse response) { |
| 2280 | + statistics.setTotalDocs(response.getTotalDocs()); |
| 2281 | + statistics.setNumDocsScanned(response.getNumDocsScanned()); |
| 2282 | + statistics.setNumEntriesScannedInFilter(response.getNumEntriesScannedInFilter()); |
| 2283 | + statistics.setNumEntriesScannedPostFilter(response.getNumEntriesScannedPostFilter()); |
| 2284 | + statistics.setNumSegmentsQueried(response.getNumSegmentsQueried()); |
| 2285 | + statistics.setNumSegmentsProcessed(response.getNumSegmentsProcessed()); |
| 2286 | + statistics.setNumSegmentsMatched(response.getNumSegmentsMatched()); |
| 2287 | + statistics.setNumServersQueried(response.getNumServersQueried()); |
| 2288 | + statistics.setNumSegmentsProcessed(response.getNumSegmentsProcessed()); |
| 2289 | + statistics.setNumServersResponded(response.getNumServersResponded()); |
| 2290 | + statistics.setNumGroupsLimitReached(response.isNumGroupsLimitReached()); |
| 2291 | + statistics.setNumExceptions(response.getExceptionsSize()); |
| 2292 | + statistics.setOfflineThreadCpuTimeNs(response.getOfflineThreadCpuTimeNs()); |
| 2293 | + statistics.setRealtimeThreadCpuTimeNs(response.getRealtimeThreadCpuTimeNs()); |
| 2294 | + statistics.setOfflineSystemActivitiesCpuTimeNs(response.getOfflineSystemActivitiesCpuTimeNs()); |
| 2295 | + statistics.setRealtimeSystemActivitiesCpuTimeNs(response.getRealtimeSystemActivitiesCpuTimeNs()); |
| 2296 | + statistics.setOfflineResponseSerializationCpuTimeNs(response.getOfflineResponseSerializationCpuTimeNs()); |
| 2297 | + statistics.setRealtimeResponseSerializationCpuTimeNs(response.getRealtimeResponseSerializationCpuTimeNs()); |
| 2298 | + statistics.setOfflineTotalCpuTimeNs(response.getOfflineTotalCpuTimeNs()); |
| 2299 | + statistics.setRealtimeTotalCpuTimeNs(response.getRealtimeTotalCpuTimeNs()); |
| 2300 | + statistics.setNumRowsResultSet(response.getNumRowsResultSet()); |
| 2301 | + } |
| 2302 | + |
2279 | 2303 | /** |
2280 | 2304 | * Helper class to pass the per server statistics. |
2281 | 2305 | */ |
|
0 commit comments