This is an automated email from the ASF dual-hosted git repository.

gortiz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new d3cd3cbecc MDC & marked log for user-based query response exceptions 
(#15433)
d3cd3cbecc is described below

commit d3cd3cbecc5c0b4253a9671bd429d52a11debed9
Author: Alberto Bastos <alberto.var...@startree.ai>
AuthorDate: Tue Apr 15 14:35:37 2025 +0200

    MDC & marked log for user-based query response exceptions (#15433)
---
 pinot-broker/pom.xml                                       |  4 ++++
 .../pinot/broker/api/resources/PinotClientRequest.java     | 14 ++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/pinot-broker/pom.xml b/pinot-broker/pom.xml
index ee97bb27e9..72eb7b89ae 100644
--- a/pinot-broker/pom.xml
+++ b/pinot-broker/pom.xml
@@ -45,6 +45,10 @@
       <groupId>org.apache.pinot</groupId>
       <artifactId>pinot-timeseries-planner</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
 
     <!-- Test -->
     <dependency>
diff --git 
a/pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
 
b/pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
index d55fa0336f..8da9b6f408 100644
--- 
a/pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
+++ 
b/pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
@@ -90,6 +90,9 @@ import org.apache.pinot.sql.parsers.SqlNodeAndOptions;
 import org.glassfish.jersey.server.ManagedAsync;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
 
 import static 
org.apache.pinot.spi.utils.CommonConstants.Controller.PINOT_QUERY_ERROR_CODE_HEADER;
 import static 
org.apache.pinot.spi.utils.CommonConstants.SWAGGER_AUTHORIZATION_KEY;
@@ -102,6 +105,7 @@ import static 
org.apache.pinot.spi.utils.CommonConstants.SWAGGER_AUTHORIZATION_K
 @Path("/")
 public class PinotClientRequest {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(PinotClientRequest.class);
+  private static final Marker RESPONSE_EXCEPTION_MARKER = 
MarkerFactory.getMarker("QUERY_RESPONSE_EXCEPTION");
 
   @Inject
   PinotConfiguration _brokerConf;
@@ -559,6 +563,16 @@ public class PinotClientRequest {
     if (!exceptions.isEmpty()) {
       // set the header value as first exception error code value.
       queryErrorCodeHeaderValue = exceptions.get(0).getErrorCode();
+
+      // do log with the exception flagged with a particular marker for 
filtering
+      MDC.put("queryErrorCode", Integer.toString(queryErrorCodeHeaderValue));
+      StringBuilder sb = new StringBuilder();
+      sb.append("Query processing exceptions:");
+      for (QueryProcessingException exception : exceptions) {
+        sb.append(" ").append(exception.toString());
+      }
+      LOGGER.error(RESPONSE_EXCEPTION_MARKER, sb.toString());
+      MDC.remove("queryErrorCode");
     }
 
     // returning the Response with OK status and header value.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to