Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class SparkContext(config: SparkConf) extends Logging {

// The metrics system for Driver need to be set spark.app.id to app ID.
// So it should start after we get app ID from the task scheduler and set spark.app.id.
_env.metricsSystem.start()
_env.metricsSystem.start(_conf.get(METRICS_STATIC_SOURCES_ENABLED))
// Attach the driver metrics servlet handler to the web ui after the metrics system is started.
_env.metricsSystem.getServletHandlers.foreach(handler => ui.foreach(_.attachHandler(handler)))

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/org/apache/spark/SparkEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ object SparkEnv extends Logging {
conf.set(EXECUTOR_ID, executorId)
val ms = MetricsSystem.createMetricsSystem(MetricsSystemInstances.EXECUTOR, conf,
securityManager)
ms.start()
ms.start(conf.get(METRICS_STATIC_SOURCES_ENABLED))
ms
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,12 @@ package object config {
.stringConf
.createOptional

private[spark] val METRICS_STATIC_SOURCES_ENABLED =
ConfigBuilder("spark.metrics.static.sources.enabled")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why they are static and the others are not static?

Copy link
Member

@dongjoon-hyun dongjoon-hyun Nov 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apache Spark defines like the following.

private[spark] object StaticSources {
  /**
   * The set of all static sources. These sources may be reported to from any class, including
   * static classes, without requiring reference to a SparkEnv.
   */
  val allSources = Seq(CodegenMetrics, HiveCatalogMetrics)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spark.metrics.staticSources.enabled might look better. Using static as the name space looks weird. cc @cloud-fan @Ngone51

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staticSources sounds better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that staticsSources sounds better.
BTW there is probably room for a naming convention for the "switch parameters" for enabling/disabling metrics? Currently we have:
spark.metrics.static.sources.enabled
spark.app.status.metrics.enabled
spark.sql.streaming.metricsEnabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #26692

.doc("Whether to register static sources with the metrics system.")
.booleanConf
.createWithDefault(true)

private[spark] val PYSPARK_DRIVER_PYTHON = ConfigBuilder("spark.pyspark.driver.python")
.stringConf
.createOptional
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.metrics.source

import org.apache.spark.{LocalSparkContext, SparkConf, SparkContext, SparkFunSuite}
import org.apache.spark.internal.config.METRICS_STATIC_SOURCES_ENABLED

class SourceConfigSuite extends SparkFunSuite with LocalSparkContext {

test("Test configuration for adding static sources registration") {
val conf = new SparkConf()
conf.set(METRICS_STATIC_SOURCES_ENABLED, true)
val sc = new SparkContext("local", "test", conf)
try {
val metricsSystem = sc.env.metricsSystem

// Static sources should be registered
assert (metricsSystem.getSourcesByName("CodeGenerator").nonEmpty)
assert (metricsSystem.getSourcesByName("HiveExternalCatalog").nonEmpty)
} finally {
sc.stop()
}
}

test("Test configuration for skipping static sources registration") {
val conf = new SparkConf()
conf.set(METRICS_STATIC_SOURCES_ENABLED, false)
val sc = new SparkContext("local", "test", conf)
try {
val metricsSystem = sc.env.metricsSystem

// Static sources should not be registered
assert (metricsSystem.getSourcesByName("CodeGenerator").isEmpty)
assert (metricsSystem.getSourcesByName("HiveExternalCatalog").isEmpty)
} finally {
sc.stop()
}
}

}
8 changes: 8 additions & 0 deletions docs/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -923,13 +923,17 @@ This is the component with the largest amount of instrumented metrics
- memory.remainingOnHeapMem_MB

- namespace=HiveExternalCatalog
- **note:**: these metrics are conditional to a configuration parameter:
`spark.metrics.static.sources.enabled` (default is true)
- fileCacheHits.count
- filesDiscovered.count
- hiveClientCalls.count
- parallelListingJobCount.count
- partitionsFetched.count

- namespace=CodeGenerator
- **note:**: these metrics are conditional to a configuration parameter:
`spark.metrics.static.sources.enabled` (default is true)
- compilationTime (histogram)
- generatedClassSize (histogram)
- generatedMethodSize (histogram)
Expand Down Expand Up @@ -1047,13 +1051,17 @@ when running in local mode.
- shuffle-server.usedHeapMemory

- namespace=HiveExternalCatalog
- **note:**: these metrics are conditional to a configuration parameter:
`spark.metrics.static.sources.enabled` (default is true)
- fileCacheHits.count
- filesDiscovered.count
- hiveClientCalls.count
- parallelListingJobCount.count
- partitionsFetched.count

- namespace=CodeGenerator
- **note:**: these metrics are conditional to a configuration parameter:
`spark.metrics.static.sources.enabled` (default is true)
- compilationTime (histogram)
- generatedClassSize (histogram)
- generatedMethodSize (histogram)
Expand Down