You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by hv...@apache.org on 2024/09/23 15:22:18 UTC

(spark) branch master updated: [SPARK-49747][CONNECT] Migrate connect/ files to structured logging

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3b5c1d6baeb2 [SPARK-49747][CONNECT] Migrate connect/ files to structured logging
3b5c1d6baeb2 is described below

commit 3b5c1d6baeb239c75c182513b3fad37d532d9f9f
Author: Nemanja Boric <ne...@databricks.com>
AuthorDate: Mon Sep 23 11:22:07 2024 -0400

    [SPARK-49747][CONNECT] Migrate connect/ files to structured logging
    
    ### What changes were proposed in this pull request?
    
    We are moving one missing piece in SparkConnect to MDC-based logging.
    
    ### Why are the changes needed?
    
    As part of the greater migration to structured logging.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Compilation/existing tests.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #48195 from nemanja-boric-databricks/mdc-connect.
    
    Authored-by: Nemanja Boric <ne...@databricks.com>
    Signed-off-by: Herman van Hovell <he...@databricks.com>
---
 .../apache/spark/sql/connect/execution/ExecuteThreadRunner.scala    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/execution/ExecuteThreadRunner.scala b/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/execution/ExecuteThreadRunner.scala
index fe43edb5c621..e75654e2c384 100644
--- a/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/execution/ExecuteThreadRunner.scala
+++ b/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/execution/ExecuteThreadRunner.scala
@@ -27,7 +27,7 @@ import org.apache.commons.lang3.StringUtils
 
 import org.apache.spark.SparkSQLException
 import org.apache.spark.connect.proto
-import org.apache.spark.internal.Logging
+import org.apache.spark.internal.{Logging, LogKeys, MDC}
 import org.apache.spark.sql.connect.common.ProtoUtils
 import org.apache.spark.sql.connect.planner.SparkConnectPlanner
 import org.apache.spark.sql.connect.service.{ExecuteHolder, ExecuteSessionTag, SparkConnectService}
@@ -113,7 +113,7 @@ private[connect] class ExecuteThreadRunner(executeHolder: ExecuteHolder) extends
       } catch {
         // Need to catch throwable instead of NonFatal, because e.g. InterruptedException is fatal.
         case e: Throwable =>
-          logDebug(s"Exception in execute: $e")
+          logDebug(log"Exception in execute: ${MDC(LogKeys.EXCEPTION, e)}")
           // Always cancel all remaining execution after error.
           executeHolder.sessionHolder.session.sparkContext.cancelJobsWithTag(
             executeHolder.jobTag,
@@ -298,7 +298,7 @@ private[connect] class ExecuteThreadRunner(executeHolder: ExecuteHolder) extends
         ProtoUtils.abbreviate(request, maxLevel = 8).toString)
     } catch {
       case NonFatal(e) =>
-        logWarning("Fail to extract debug information", e)
+        logWarning(log"Fail to extract debug information: ${MDC(LogKeys.EXCEPTION, e)}")
         "UNKNOWN"
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org