Skip to content

Commit ecb5690

Browse files
committed
Include the last Spark method in the full stack trace. Otherwise it is not visible if the stage name is overridden.
1 parent d00a85b commit ecb5690

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ private[spark] object Utils extends Logging {
819819
var firstUserFile = "<unknown>"
820820
var firstUserLine = 0
821821
var insideSpark = true
822-
var userCallStack = new ArrayBuffer[String]
822+
var callStack = new ArrayBuffer[String]() :+ "<unknown>"
823823

824824
for (el <- trace) {
825825
if (insideSpark) {
@@ -830,20 +830,21 @@ private[spark] object Utils extends Logging {
830830
} else {
831831
el.getMethodName
832832
}
833+
callStack(0) = el.toString // Put last Spark method on top of the stack trace.
833834
} else {
834835
firstUserLine = el.getLineNumber
835836
firstUserFile = el.getFileName
836-
userCallStack += el.toString
837+
callStack += el.toString
837838
insideSpark = false
838839
}
839840
} else {
840-
userCallStack += el.toString
841+
callStack += el.toString
841842
}
842843
}
843-
val userCallStackDepth = System.getProperty("spark.callstack.depth", "20").toInt
844+
val callStackDepth = System.getProperty("spark.callstack.depth", "20").toInt
844845
CallSite(
845846
short = "%s at %s:%s".format(lastSparkMethod, firstUserFile, firstUserLine),
846-
long = userCallStack.take(userCallStackDepth).mkString("\n"))
847+
long = callStack.take(callStackDepth).mkString("\n"))
847848
}
848849

849850
/** Return a string containing part of a file from byte 'start' to 'end'. */

0 commit comments

Comments
 (0)