I remembered there was a PR about doing similar thing ( https://github.com/apache/spark/pull/18406). From my understanding, this seems like a quite specific requirement, it may requires code change to support your needs.
Thanks Saisai Sergey Zhemzhitsky <szh.s...@gmail.com> 于2019年5月4日周六 下午4:44写道: > Hello Spark Users! > > Just wondering whether it is possible to register a metric source without > metrics known in advance and add the metrics themselves to this source > later on? > > It seems that currently MetricSystem puts all the metrics from the > source's MetricRegistry into a shared MetricRegistry of a MetricSystem > during metric source registration [1]. > > So in case there is a new metric with a new name added to the source's > registry after this source registration, then this new metric will not be > reported to the sinks. > > What I'd like to achieve is to be able to register new metrics with new > names dynamically using a single metric source. > Is it somehow possible? > > > [1] > https://github.com/apache/spark/blob/51de86baed0776304c6184f2c04b6303ef48df90/core/src/main/scala/org/apache/spark/metrics/MetricsSystem.scala#L162 >