sryza commented on code in PR #53540:
URL: https://github.com/apache/spark/pull/53540#discussion_r2666513702


##########
core/src/main/scala/org/apache/spark/util/ShutdownHookManager.scala:
##########
@@ -223,11 +230,26 @@ private [util] class SparkShutdownHookManager {
 
 }
 
-private class SparkShutdownHook(private val priority: Int, hook: () => Unit)
-  extends Comparable[SparkShutdownHook] {
+private class SparkShutdownHook(
+    private val priority: Int,
+    private val name: String,
+    hook: () => Unit,
+    clock: Clock = new SystemClock())
+  extends Comparable[SparkShutdownHook] with Logging {
 
   override def compareTo(other: SparkShutdownHook): Int = 
other.priority.compareTo(priority)
 
-  def run(): Unit = hook()
-
+  def run(): Unit = {
+    val startTime = clock.getTimeMillis()
+    try {
+      hook()
+      logInfo(s"Shutdown hook completed: $name (priority=$priority, " +
+        s"time=${clock.getTimeMillis() - startTime}ms)")
+    } catch {
+      case e: Throwable =>
+        logError(s"Shutdown hook failed: $name (priority=$priority, " +
+          s"time=${clock.getTimeMillis() - startTime}ms)", e)
+        throw e
+    }
+  }

Review Comment:
   Thanks for the heads up @mridulm . Will this PR add log lines for end 
user-facing CLIs like `pyspark` and `spark-pipelines`? Is there a way we'd be 
able to disable this by default if so? Perhaps just for Connect client 
processes who aren't running their own `SparkContext`?
   
   Ideally we can find a way to balance a clean end-user experience with 
exposing more detailed observability to operators who are interested in it.



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