squito commented on a change in pull request #24132: [SPARK-27189][CORE] Add 
Executor metrics and memory usage instrumentation to the metrics system
URL: https://github.com/apache/spark/pull/24132#discussion_r349733355
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/executor/ExecutorMetricsSource.scala
 ##########
 @@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.executor
+
+import com.codahale.metrics.{Gauge, MetricRegistry}
+
+import org.apache.spark.metrics.ExecutorMetricType
+import org.apache.spark.metrics.source.Source
+
+private[spark] class ExecutorMetricsSource extends Source {
+
+  override val metricRegistry = new MetricRegistry()
+  override val sourceName = "ExecutorMetrics"
+  @volatile var metricsSnapshot: Array[Long] = 
Array.fill(ExecutorMetricType.numMetrics)(0L)
+
+  // called by ExecutorMetricsPoller
+  def updateMetricsSnapshot(metricsUpdates: Array[Long]): Unit = {
+    metricsSnapshot = metricsUpdates
+  }
+
+  class ExecutorMetricGauge(idx: Int) extends Gauge[Long] {
+    def getValue: Long = metricsSnapshot(idx)
+  }
+
+  def register: Unit = {
+    // This looks like a bunch of independent gauges as far the metric system
+    // is concerned, but actually they're all using one shared snapshot.
 
 Review comment:
   I know this was my comment originally, but I meant it more to compare 
against other approaches, I think its confusing for someone new to this trying 
to understand what is going on here.  I'd change to something like
   
   This takes the values of the metrics we have already computed and stored in 
our snapshot, and exposes them as individual gauges for the metric system.  
This means the value never gets updated when polled from the metric system, 
only when we decide the ExecutorMetricPoller updates the snapshot.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to