diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontAutoConfiguration.java index 62a1186dd505..3799d852378a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.wavefront; -import java.util.function.Supplier; - import com.wavefront.sdk.common.WavefrontSender; import com.wavefront.sdk.common.application.ApplicationTags; @@ -46,39 +44,18 @@ @EnableConfigurationProperties(WavefrontProperties.class) public class WavefrontAutoConfiguration { - /** - * Default value for the Wavefront Service name if {@code spring.application.name} is - * not set. - * @see Wavefront - * Application Tags - */ - private static final String DEFAULT_SERVICE_NAME = "unnamed_service"; - - /** - * Default value for the Wavefront Application name. - * @see Wavefront - * Application Tags - */ - private static final String DEFAULT_APPLICATION_NAME = "unnamed_application"; - @Bean @ConditionalOnMissingBean public ApplicationTags wavefrontApplicationTags(Environment environment, WavefrontProperties properties) { Application application = properties.getApplication(); - String serviceName = getName(application.getServiceName(), - () -> environment.getProperty("spring.application.name", DEFAULT_SERVICE_NAME)); - String applicationName = getName(application.getName(), () -> DEFAULT_APPLICATION_NAME); + String serviceName = application.getServiceName(); + serviceName = (StringUtils.hasText(serviceName)) ? serviceName + : environment.getProperty("spring.application.name", "unnamed_service"); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); - ApplicationTags.Builder builder = new ApplicationTags.Builder(applicationName, serviceName); + ApplicationTags.Builder builder = new ApplicationTags.Builder(application.getName(), serviceName); map.from(application::getClusterName).to(builder::cluster); map.from(application::getShardName).to(builder::shard); return builder.build(); } - private String getName(String value, Supplier fallback) { - return (StringUtils.hasText(value)) ? value : fallback.get(); - } - } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontProperties.java index 2008dd3bc353..635efd90e7be 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontProperties.java @@ -53,6 +53,9 @@ public class WavefrontProperties { */ private String apiToken; + /** + * Application configuration. + */ private final Application application = new Application(); /** @@ -150,24 +153,23 @@ private boolean usesProxy() { public static class Application { /** - * Wavefront Application name used in ApplicationTags. Defaults to - * 'unnamed_application'. + * Wavefront 'Application' name used in ApplicationTags. */ - private String name; + private String name = "unnamed_application"; /** - * Wavefront Service name used in ApplicationTags, falling back to - * 'spring.application.name'. If both are unset it defaults to 'unnamed_service'. + * Wavefront 'Service' name used in t, falling back to 'spring.application.name'. + * If both are unset it defaults to 'unnamed_service'. */ private String serviceName; /** - * Optional Wavefront Cluster name used in ApplicationTags. + * Wavefront Cluster name used in ApplicationTags. */ private String clusterName; /** - * Optional Wavefront Shard name used in ApplicationTags. + * Wavefront Shard name used in ApplicationTags. */ private String shardName;