Github user steveloughran commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9571#discussion_r74962913
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala ---
    @@ -226,6 +259,135 @@ class HistoryServer(
     }
     
     /**
    + * An abstract implementation of the metrics [[Source]] trait with some 
common operations.
    + */
    +private[history] abstract class HistoryMetricSource(val prefix: String) 
extends Source {
    +  override val metricRegistry = new MetricRegistry()
    +
    +  /**
    +   * Register a sequence of metrics
    +   * @param metrics sequence of metrics to register
    +   */
    +  def register(metrics: Seq[(String, Metric)]): Unit = {
    +    metrics.foreach { case (name, metric) =>
    +      metricRegistry.register(fullname(name), metric)
    +    }
    +  }
    +
    +  /**
    +   * Create the full name of a metric by prepending the prefix to the name
    +   * @param name short name
    +   * @return the full name to use in registration
    +   */
    +  def fullname(name: String): String = {
    +    MetricRegistry.name(prefix, name)
    +  }
    +
    +  /**
    +   * Dump the counters and gauges.
    +   * @return a string for logging and diagnostics -not for parsing by 
machines.
    +   */
    +  override def toString: String = {
    +    val sb = new StringBuilder(s"Metrics for $sourceName:\n")
    +    sb.append("  Counters\n")
    +    metricRegistry.getCounters.asScala.foreach { entry =>
    +        sb.append("    ").append(entry._1).append(" = 
").append(entry._2.getCount).append('\n')
    +    }
    +    sb.append("  Gauges\n")
    +    metricRegistry.getGauges.asScala.foreach { entry =>
    --- End diff --
    
    done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to