szhem commented on a change in pull request #24556: [SPARK-27641][CORE] Fix
MetricsSystem to remove unregistered source correctly
URL: https://github.com/apache/spark/pull/24556#discussion_r283147453
##########
File path: core/src/main/scala/org/apache/spark/metrics/MetricsSystem.scala
##########
@@ -152,6 +152,12 @@ private[spark] class MetricsSystem private (
} else { defaultName }
}
+ private[spark] def getRegisteredNames(source: Source): Seq[String] = {
+ val sourceNamePrefix = buildRegistryName(source)
+ val metricNames = source.metricRegistry.getMetrics.keySet()
+ JavaConverters.asScalaSet(metricNames).map(k =>
s"${sourceNamePrefix}.${k}").toSeq
Review comment:
1. There is `MetricRegistry.name` method to create names instead of string
interpolation.
2. It seems that JavaConverters are not used in such a way [throughout the
codebase](https://github.com/apache/spark/search?l=Scala&q=asScala)
3. The result of the method is `ArrayBuffer`, so every lookup is `O(N)`.
What is the reason of converting a `Set` into a `Seq`?
----------------------------------------------------------------
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]