Copilot commented on code in PR #17457:
URL: https://github.com/apache/pinot/pull/17457#discussion_r2663658987


##########
pinot-common/src/main/java/org/apache/pinot/common/response/BrokerResponse.java:
##########
@@ -41,6 +42,21 @@
  */
 public interface BrokerResponse {
   static final Logger LOGGER = LoggerFactory.getLogger(BrokerResponse.class);
+  static final EnumSet<QueryErrorCode> SYSTEM_ERROR_CODES = EnumSet.of(

Review Comment:
   The `SYSTEM_ERROR_CODES` field should have an explicit visibility modifier. 
According to Java best practices, interface fields are public, static, and 
final by default, but explicitly declaring `public` improves code clarity and 
maintainability.
   ```suggestion
     public static final EnumSet<QueryErrorCode> SYSTEM_ERROR_CODES = 
EnumSet.of(
   ```



##########
pinot-common/src/main/java/org/apache/pinot/common/response/BrokerResponse.java:
##########
@@ -76,6 +92,8 @@ default String toMetadataJsonString()
    * This method ensures we emit metrics for all queries that have exceptions 
with a one-to-one mapping.
    */
   default void emitBrokerResponseMetrics(BrokerMetrics brokerMetrics) {
+    boolean isSystemError = false;
+    boolean isUserError = false;

Review Comment:
   If a query has both system and user errors, both `isSystemError` and 
`isUserError` will be true, resulting in both metrics being incremented for the 
same query. This contradicts the PR's goal of providing a single per-query 
classification. Consider using mutually exclusive classification logic, such as 
prioritizing system errors over user errors, or emitting only one metric based 
on the most severe error type.



##########
pinot-common/src/main/java/org/apache/pinot/common/response/BrokerResponse.java:
##########
@@ -85,6 +103,18 @@ default void emitBrokerResponseMetrics(BrokerMetrics 
brokerMetrics) {
         queryErrorCode = QueryErrorCode.UNKNOWN;
       }
       
brokerMetrics.addMeteredGlobalValue(BrokerMeter.getQueryErrorMeter(queryErrorCode),
 1);
+      if (SYSTEM_ERROR_CODES.contains(queryErrorCode)) {
+        isSystemError = true;
+      } else {
+        isUserError = true;
+      }

Review Comment:
   The `UNKNOWN` error code (set at line 103) will always be classified as a 
user error since it's not in `SYSTEM_ERROR_CODES`. This may not be the intended 
behavior for truly unknown errors. Consider explicitly handling 
`QueryErrorCode.UNKNOWN` or documenting this classification decision.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to