You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2021/08/09 10:49:50 UTC

[GitHub] [incubator-kyuubi] ulysses-you commented on a change in pull request #908: [KYUUBI#891]Add audit log for sql statement

ulysses-you commented on a change in pull request #908:
URL: https://github.com/apache/incubator-kyuubi/pull/908#discussion_r685084314



##########
File path: kyuubi-common/src/main/scala/org/apache/kyuubi/operation/AbstractOperation.scala
##########
@@ -69,14 +77,18 @@ abstract class AbstractOperation(opType: OperationType, session: Session)
     this.operationException = opEx
   }
 
-  protected def setState(newState: OperationState): Unit = {
+  protected def setState(newState: OperationState, audit: Boolean = true): Unit = {

Review comment:
       why do we need `audit: Boolean` ?

##########
File path: kyuubi-common/src/main/scala/org/apache/kyuubi/operation/AbstractOperation.scala
##########
@@ -118,6 +130,18 @@ abstract class AbstractOperation(opType: OperationType, session: Session)
     }
   }
 
+  def logAuditEvent(sql: String, state: OperationState): Unit = {
+    if (sql != null) {
+      val user = session.user
+      val address = session.ipAddress match {
+        case s if s != null => s
+        case _ => "unknown-ip-addr"
+      }
+
+      getAuditLog.get.info(s"user=$user\tip=$address\tstate=${state.name}\tsql=$sql\t")

Review comment:
       shall we log start time and elapsed time ? and also log app id I think it can help debug.




-- 
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: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org