Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14270#discussion_r72310984
  
    --- Diff: 
core/src/test/scala/org/apache/spark/metrics/MetricsSystemSuite.scala ---
    @@ -183,4 +184,89 @@ class MetricsSystemSuite extends SparkFunSuite with 
BeforeAndAfter with PrivateM
         assert(metricName != s"$appId.$executorId.${source.sourceName}")
         assert(metricName === source.sourceName)
       }
    +
    +  test("MetricsSystem with Executor instance, with custom namespace") {
    +    val source = new Source {
    +      override val sourceName = "dummySource"
    +      override val metricRegistry = new MetricRegistry()
    +    }
    +
    +    val appId = "testId"
    +    val appName = "testName"
    +    val executorId = "1"
    +    conf.set("spark.app.id", appId)
    +    conf.set("spark.app.name", appName)
    +    conf.set("spark.executor.id", executorId)
    +    conf.set(METRICS_NAMESPACE, "${spark.app.name}")
    +
    +    val instanceName = "executor"
    +    val driverMetricsSystem = 
MetricsSystem.createMetricsSystem(instanceName, conf, securityMgr)
    +
    +    val metricName = driverMetricsSystem.buildRegistryName(source)
    +    assert(metricName === s"$appName.$executorId.${source.sourceName}")
    +  }
    +
    +  test("MetricsSystem with Executor instance and custom namespace which is 
not set") {
    +    val source = new Source {
    +      override val sourceName = "dummySource"
    +      override val metricRegistry = new MetricRegistry()
    +    }
    +
    +    val executorId = "1"
    +    val namespaceToResolve = "${spark.doesnotexist}"
    +    conf.set("spark.executor.id", executorId)
    +    conf.set(METRICS_NAMESPACE, namespaceToResolve)
    +
    +    val instanceName = "executor"
    +    val driverMetricsSystem = 
MetricsSystem.createMetricsSystem(instanceName, conf, securityMgr)
    +
    +    val metricName = driverMetricsSystem.buildRegistryName(source)
    +    // If the user set the spark.metrics.namespace property to an 
expansion of another property
    +    // (say ${spark.doesnotexist}, the unresolved name (i.e. litterally 
${spark.doesnot})
    --- End diff --
    
    nit: "literally", then "doesnotexist"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to