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

    https://github.com/apache/spark/pull/22218#discussion_r214675924
  
    --- Diff: 
core/src/main/scala/org/apache/spark/executor/ExecutorSource.scala ---
    @@ -73,6 +76,28 @@ class ExecutorSource(threadPool: ThreadPoolExecutor, 
executorId: String) extends
         registerFileSystemStat(scheme, "write_ops", _.getWriteOps(), 0)
       }
     
    +  // Dropwizard metrics gauge measuring the executor's process CPU time.
    +  // This Gauge will try to get and return the JVM Process CPU time or 
return -1 otherwise.
    +  // The CPU time value is returned in nanoseconds.
    +  // It will use proprietary extensions such as 
com.sun.management.OperatingSystemMXBean or
    +  // com.ibm.lang.management.OperatingSystemMXBean, if available.
    +  metricRegistry.register(MetricRegistry.name("jvmCpuTime"), new 
Gauge[Long] {
    +    val mBean: MBeanServer = ManagementFactory.getPlatformMBeanServer
    +    val name = new ObjectName("java.lang", "type", "OperatingSystem")
    +    override def getValue: Long = {
    +      try {
    +        val attribute = mBean.getAttribute(name, "ProcessCpuTime")
    +        if (attribute != null) {
    --- End diff --
    
    I personally don't mind the defensive checks, because who knows what to 
really expect from these implementations? but this is OK by me. In case of a 
bad impl this would still return -1.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to