Fail gracefully when invalid CPU logs are encountered
Author: Michael Armbrust <michael@databricks.com> Closes #18 from marmbrus/parseCpuFail.
This commit is contained in:
parent
e2dc749480
commit
f03b3af719
@ -35,6 +35,7 @@ import com.twitter.jvm.CpuProfile
|
||||
*/
|
||||
package object cpu {
|
||||
|
||||
// Placeholder for DBFS.
|
||||
type FS = {
|
||||
def cp(from: String, to: String, recurse: Boolean): Boolean
|
||||
def rm(dir: String, recurse: Boolean): Boolean
|
||||
@ -102,8 +103,9 @@ package object cpu {
|
||||
case stackLine(cls, method, file, line) => new StackTraceElement(cls, method, file, line.stripPrefix(":").toInt)
|
||||
}
|
||||
|
||||
val counts = cpuLogs.groupBy($"stack").agg(count($"*")).collect().map {
|
||||
case Row(stackLines: Seq[String], count: Long) => stackLines.map(toStackElement) -> count
|
||||
val counts = cpuLogs.groupBy($"stack").agg(count($"*")).collect().flatMap {
|
||||
case Row(stackLines: Seq[String], count: Long) => stackLines.map(toStackElement) -> count :: Nil
|
||||
case other => println(s"Failed to parse $other"); Nil
|
||||
}.toMap
|
||||
val profile = new com.twitter.jvm.CpuProfile(counts, com.twitter.util.Duration.fromSeconds(10), cpuLogs.count().toInt, 0)
|
||||
|
||||
@ -122,4 +124,4 @@ package object cpu {
|
||||
s"""<a href="https://dogfood.staging.cloud.databricks.com/files/cpu.profiles/$timestamp.svg"/>CPU Usage Visualization</a>"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user