org.apache.spark.dataflint.saas.ExecutorsMetricsSerializer.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spark_2.12 Show documentation
Show all versions of spark_2.12 Show documentation
Open Source Data-Application Performance Monitoring for Apache Spark
The newest version!
package org.apache.spark.dataflint.saas
import org.apache.spark.executor.ExecutorMetrics
import org.apache.spark.metrics.ExecutorMetricType
import org.json4s.{CustomSerializer, JLong, JNull, JObject}
import org.json4s.JsonAST.JValue
class ExecutorsMetricsSerializer extends CustomSerializer[ExecutorMetrics](implicit format => (
{
case json: JValue =>
val metricsMap = json.extract[Map[String, Long]]
val metrics = new ExecutorMetrics(metricsMap)
metrics
},
{
case Some(metrics: ExecutorMetrics) =>
val metricsMap = ExecutorMetricType.metricToOffset.map { case (metric, _) =>
metric -> metrics.getMetricValue(metric)
}
val metricsObj = JObject(metricsMap.map { case (k, v) => k -> JLong(v) }.toList)
metricsObj
case None => JNull
}
))
© 2015 - 2025 Weber Informatics LLC | Privacy Policy