igreenfield commented on a change in pull request #28756:
URL: https://github.com/apache/spark/pull/28756#discussion_r438570609



##########
File path: core/src/main/scala/org/apache/spark/executor/Executor.scala
##########
@@ -322,11 +322,15 @@ private[spark] class Executor(
     val taskId = taskDescription.taskId
     val threadName = s"Executor task launch worker for task $taskId"
     val taskName = taskDescription.name
-    val mdcProperties = taskDescription.properties.asScala
-      .filter(_._1.startsWith("mdc.")).map { item =>
+    val mdcProperties = (taskDescription.properties.asScala ++
+      Seq((Executor.TASK_MDC_KEY, taskName)))
+      .filter(_._1.startsWith(Executor.MDC_KEY)).map { item =>
         val key = item._1.substring(4)
+        if (key == Executor.TASK_MDC_KEY && item._2 != taskName) {
+          logWarning(s"Override mdc.taskName is not allowed, ignore 
${item._2}")

Review comment:
       Why we do not let override the task name in MDC?

##########
File path: core/src/main/scala/org/apache/spark/executor/Executor.scala
##########
@@ -969,4 +992,7 @@ private[spark] object Executor {
   // task is fully deserialized. When possible, the 
TaskContext.getLocalProperty call should be
   // used instead.
   val taskDeserializationProps: ThreadLocal[Properties] = new 
ThreadLocal[Properties]
+
+  val MDC_KEY = "mdc."
+  val TASK_MDC_KEY = s"${MDC_KEY}taskName"

Review comment:
       if you change this key you need also to update the docs




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