FrankChen021 commented on a change in pull request #9919:
URL: https://github.com/apache/druid/pull/9919#discussion_r431884749



##########
File path: server/src/main/java/org/apache/druid/metadata/SQLProfileLogger.java
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.metadata;
+
+import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.tweak.SQLLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * record the execution time of SQL to log file
+ */
+public class SQLProfileLogger implements SQLLog
+{
+  static Logger logger = LoggerFactory.getLogger(SQLProfileLogger.class);
+
+  @Override
+  public void logBeginTransaction(Handle h)
+  {
+  }
+
+  @Override
+  public void logCommitTransaction(long time, Handle h)
+  {
+  }
+
+  @Override
+  public void logRollbackTransaction(long time, Handle h)
+  {
+  }
+
+  @Override
+  public void logObtainHandle(long time, Handle h)
+  {
+  }
+
+  @Override
+  public void logReleaseHandle(Handle h)
+  {
+  }
+
+  @Override
+  public void logSQL(long time, String sql)
+  {
+    logger.info("statement:[{}] took {} millis", sql, time);

Review comment:
       In our practice, it's useful to know the time cost on the underlying 
metadata storage. If it's at INFO level, when we feel that there may be some 
problems at db level as we have encountered in  #9755  , we could tell the 
problems right away. Or we need to modify the configuration file to set the 
logger to correct level and then reboot the nodes one by one to make it take 
effect. In production, usually it's impossible to reboot a node just because we 
want to see more logs. 
   
   2nd, druid doesn't interact with the meta storage very frequently, so these 
extra logs won't be a burden




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



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

Reply via email to