[SPARK-3377] [SPARK-3610] Metrics can be accidentally aggregated / History server log name should not be based on user input

This PR is another solution for #2250 

I'm using codahale base MetricsSystem of Spark with JMX or Graphite, and I saw following 2 problems.

(1) When applications which have same spark.app.name run on cluster at the same time, some metrics names are mixed. For instance, if 2+ application is running on the cluster at the same time, each application emits the same named metric like "SparkPi.DAGScheduler.stage.failedStages" and Graphite cannot distinguish the metrics is for which application.

(2) When 2+ executors run on the same machine, JVM metrics of each executors are mixed. For instance, 2+ executors running on the same node can emit the same named metric "jvm.memory" and Graphite cannot distinguish the metrics is from which application.

And there is an similar issue. The directory for event logs is named using application name.
Application name is defined by user and the name can includes illegal character for path names.
Further more, the directory name consists of application name and System.currentTimeMillis even though each application has unique Application ID so if we run jobs which have same name, it's difficult to identify which directory is for which application.

Closes #2250 
Closes #1067
How about
```
def buildRegistryName(...): String = {
  val appId = conf.getOption("spark.app.id")
  val executorId = conf.getOption("spark.executor.id")
  if (appId.isDefined && executorId.isDefined) {
    return MetricRegistry.name(appId.get, executorId.get, source.sourceName)
  }
  val defaultName = MetricRegistry.name(source.sourceName)
  val warningMsg = s"Using default name $defaultName for source because %s is not set"
  if (appId.isEmpty) { logWarning(warningMsg.format("spark.app.id")) }
  if (executorId.isEmpty) { logWarning(warningMsg.format("spark.executor.id")) }
  defaultName
}
```