Skip to content

Commit

Permalink
Use spark application name when service is set to spark (#7252)
Browse files Browse the repository at this point in the history
DD_SPARK_APP_NAME_AS_SERVICE also use spark.app.name as the default service if service is set to spark

USM can auto-infer the service to spark, in this case we still want to use the spark app name as the service
  • Loading branch information
paul-laffon-dd committed Jul 1, 2024
1 parent 97e2337 commit bf4eb15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1118,13 +1118,24 @@ private static String getDatabricksServiceName(SparkConf conf, String databricks
}

private static String getSparkServiceName(SparkConf conf, boolean isRunningOnDatabricks) {
if (Config.get().isServiceNameSetByUser()
|| !Config.get().useSparkAppNameAsService()
|| isRunningOnDatabricks) {
// If config is not set or running on databricks, not changing the service name
if (!Config.get().useSparkAppNameAsService() || isRunningOnDatabricks) {
return null;
}

return conf.get("spark.app.name", null);
// Keep service set by user, except if it is only "spark" that can be set by USM
String serviceName = Config.get().getServiceName();
if (Config.get().isServiceNameSetByUser() && !"spark".equals(serviceName)) {
log.debug("Service '{}' explicitly set by user, not using the application name", serviceName);
return null;
}

String sparkAppName = conf.get("spark.app.name", null);
if (sparkAppName != null) {
log.info("Using Spark application name '{}' as the Datadog service name", sparkAppName);
}

return sparkAppName;
}

private static String getDatabricksRunName(SparkConf conf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@ abstract class AbstractSparkTest extends AgentTestRunner {

where:
ddService | sparkAppNameAsService | appName | isRunningOnDatabricks | expectedService
"foobar" | true | "some_app" | true | "(?!.*some_app).*"
"foobar" | true | "some_app" | false | "(?!.*some_app).*"
"spark" | true | "some_app" | false | "some_app"
null | true | "some_app" | true | "(?!.*some_app).*"
null | true | "some_app" | false | "some_app"
null | false | "some_app" | false | "(?!.*some_app).*"
Expand Down

0 comments on commit bf4eb15

Please sign in to comment.