mcvsubbu commented on a change in pull request #4356: Emit metrics to track
performance against specific Service-Level-Objectives (SLO)
URL: https://github.com/apache/incubator-pinot/pull/4356#discussion_r296919188
##########
File path:
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
##########
@@ -361,6 +384,52 @@ private boolean forceLog(BrokerResponse brokerResponse,
long totalTimeMs) {
return false;
}
+
+ private void scoreResponse(BrokerResponse response, RequestStatistics stats)
{
+
+ try {
+
+ if (response == BrokerResponseNative.EMPTY_RESULT || response ==
BrokerResponseNative.NO_TABLE_RESULT
+ || response.getNumServersResponded() == 0 ||
!response.getProcessingExceptions().isEmpty()) {
+ // error response
+ _brokerMetrics.addMeteredTableValue(stats.getTableName(),
BrokerMeter.ERROR_RESPONSE, 1);
+ return;
+ }
+
+ if ((response.getNumServersQueried() > response.getNumServersResponded())
+ || stats.getFanoutType() == RequestStatistics.FanoutType.HYBRID
+ && response.getNumConsumingSegmentsQueried() <= 0 ||
response.isNumGroupsLimitReached()) {
+ // partial response
+ _brokerMetrics.addMeteredTableValue(stats.getTableName(),
BrokerMeter.PARTIAL_RESPONSE, 1);
+ return;
+ }
+
+ TableConfig tableConfig = _tableConfigCache.get(stats.getTableName());
+ if (tableConfig != null && tableConfig.getSloConfig() != null) {
+ SloConfig sloConfig = tableConfig.getSloConfig();
+ if (sloConfig.getFreshnessLagMs() > 0 && (stats.getFanoutType() ==
RequestStatistics.FanoutType.HYBRID
+ || stats.getFanoutType() == RequestStatistics.FanoutType.REALTIME)
+ && response.getMinConsumingFreshnessTimeMs() > 0 &&
(System.currentTimeMillis() - response.getMinConsumingFreshnessTimeMs() >
sloConfig.getFreshnessLagMs())) {
+ // stale response
+ _brokerMetrics.addMeteredTableValue(stats.getTableName(),
BrokerMeter.STALE_RESPONSE, 1);
+ return;
+ }
+
+ if (sloConfig.getLatencyMs() > 0 && stats.getProcessingTimeMillis() >
sloConfig.getLatencyMs()) {
+ // latent response
+ _brokerMetrics.addMeteredTableValue(stats.getTableName(),
BrokerMeter.LATENT_RESPONSE, 1);
+ return;
+ }
+ }
+
+ _brokerMetrics.addMeteredTableValue(stats.getTableName(),
BrokerMeter.HEALTHY_RESPONSE, 1);
+ } catch (Exception e) {
+ // don't fail the request due to any issues related to tracking!
+ LOGGER.error("Failed to score request with id={} table={} cache={}",
stats.getRequestId(), stats.getTableName(),
Review comment:
I can understand why you want to log here, but we need to be careful not to
flood the logs.... You may want to consider the alternative of raising a
metric? Or logging once every N requests? Not sure though.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]