Skip to content

Commit 1c57da3

Browse files
LucaCanalidongjoon-hyun
authored andcommitted
[SPARK-25277][YARN] YARN applicationMaster metrics should not register static metrics
## What changes were proposed in this pull request? YARN applicationMaster metrics registration introduced in SPARK-24594 causes further registration of static metrics (Codegenerator and HiveExternalCatalog) and of JVM metrics, which I believe do not belong in this context. This looks like an unintended side effect of using the start method of [[MetricsSystem]]. A possible solution proposed here, is to introduce startNoRegisterSources to avoid these additional registrations of static sources and of JVM sources in the case of YARN applicationMaster metrics (this could be useful for other metrics that may be added in the future). ## How was this patch tested? Manually tested on a YARN cluster, Closes #22279 from LucaCanali/YarnMetricsRemoveExtraSourceRegistration. Lead-authored-by: Luca Canali <luca.canali@cern.ch> Co-authored-by: LucaCanali <luca.canali@cern.ch> Signed-off-by: Marcelo Vanzin <vanzin@cloudera.com>
1 parent b41795a commit 1c57da3

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

core/src/main/scala/org/apache/spark/metrics/MetricsSystem.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ private[spark] class MetricsSystem private (
9494

9595
metricsConfig.initialize()
9696

97-
def start() {
97+
def start(registerStaticSources: Boolean = true) {
9898
require(!running, "Attempting to start a MetricsSystem that is already running")
9999
running = true
100-
StaticSources.allSources.foreach(registerSource)
101-
registerSources()
100+
if (registerStaticSources) {
101+
StaticSources.allSources.foreach(registerSource)
102+
registerSources()
103+
}
102104
registerSinks()
103105
sinks.foreach(_.start)
104106
}

resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends
451451
val ms = MetricsSystem.createMetricsSystem("applicationMaster", sparkConf, securityMgr)
452452
val prefix = _sparkConf.get(YARN_METRICS_NAMESPACE).getOrElse(appId)
453453
ms.registerSource(new ApplicationMasterSource(prefix, allocator))
454-
ms.start()
454+
// do not register static sources in this case as per SPARK-25277
455+
ms.start(false)
455456
metricsSystem = Some(ms)
456457
reporterThread = launchReporterThread()
457458
}

0 commit comments

Comments
 (0)