diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java index edf919f4e5..e10cedd625 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java @@ -33,7 +33,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; - /** * {@link EnableAutoConfiguration Auto-configuration} for exporting metrics to Wavefront. * @@ -57,7 +56,9 @@ public class WavefrontMetricsExportAutoConfiguration { @Bean(destroyMethod = "stop") @ConditionalOnMissingBean - public WavefrontMeterRegistry wavefrontMeterRegistry(WavefrontConfig config, Clock clock) { + public WavefrontMeterRegistry wavefrontMeterRegistry(WavefrontConfig config, + Clock clock) { return new WavefrontMeterRegistry(config, clock); } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontProperties.java index b05bbb3259..bb9fa170ae 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontProperties.java @@ -16,6 +16,8 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront; +import java.net.URI; + import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryProperties; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -27,36 +29,41 @@ import org.springframework.boot.context.properties.ConfigurationProperties; */ @ConfigurationProperties("management.metrics.export.wavefront") public class WavefrontProperties extends StepRegistryProperties { - /** - * The URI to publish metrics to. The URI could represent a Wavefront sidecar or the - * Wavefront API host. This host could also represent an internal proxy set up in your environment - * that forwards metrics data to the Wavefront API host. - * - * If publishing metrics to a Wavefront proxy (as described in https://docs.wavefront.com/proxies_installing.html), - * the host must be in the proxy://HOST:PORT format. - */ - private String uri; /** - * Uniquely identifies the app instance that is publishing metrics to Wavefront. Defaults to the local host name. + * URI to which metrics are published. May represent a Wavefront sidecar or the + * Wavefront API host. This host could also represent an internal proxy set up in your + * environment that forwards metrics data to the Wavefront API host. + * + * If publishing metrics to a Wavefront proxy (as described in + * https://docs.wavefront.com/proxies_installing.html), the host must be in the + * proxy://HOST:PORT format. + */ + private URI uri; + + /** + * Unique identifier for the app instance that is the source of metrics being + * published to Wavefront. Defaults to the local host name. */ private String source; /** - * Required when publishing directly to the Wavefront API host, otherwise does nothing. + * API token used when publishing metrics directly to the Wavefront API host. */ private String apiToken; /** - * Global prefix to separate metrics originating from this app's white box instrumentation from those originating from other Wavefront integrations when viewed in the Wavefront UI. + * Global prefix to separate metrics originating from this app's white box + * instrumentation from those originating from other Wavefront integrations when + * viewed in the Wavefront UI. */ private String globalPrefix; - public String getUri() { + public URI getUri() { return this.uri; } - public void setUri(String uri) { + public void setUri(URI uri) { this.uri = uri; } @@ -83,4 +90,5 @@ public class WavefrontProperties extends StepRegistryProperties { public void setGlobalPrefix(String globalPrefix) { this.globalPrefix = globalPrefix; } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java index 0812c5498c..d2c6b1ca81 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java @@ -26,7 +26,8 @@ import org.springframework.boot.actuate.autoconfigure.metrics.export.properties. * @author Jon Schneider * @since 2.0.0 */ -public class WavefrontPropertiesConfigAdapter extends PropertiesConfigAdapter implements WavefrontConfig { +public class WavefrontPropertiesConfigAdapter + extends PropertiesConfigAdapter implements WavefrontConfig { public WavefrontPropertiesConfigAdapter(WavefrontProperties properties) { super(properties); @@ -39,7 +40,7 @@ public class WavefrontPropertiesConfigAdapter extends PropertiesConfigAdapter assertThat(context).hasFailed()); + } + @Test public void autoConfigurationCanBeDisabled() { this.runner.withUserConfiguration(BaseConfiguration.class) - .withPropertyValues( - "management.metrics.export.wavefront.enabled=false") + .withPropertyValues("management.metrics.export.wavefront.enabled=false") .run((context) -> assertThat(context) .doesNotHaveBean(WavefrontMeterRegistry.class) .doesNotHaveBean(WavefrontConfig.class)); @@ -64,8 +69,7 @@ public class WavefrontMetricsExportAutoConfigurationTests { @Test public void allowsConfigToBeCustomized() { - this.runner - .withUserConfiguration(CustomConfigConfiguration.class) + this.runner.withUserConfiguration(CustomConfigConfiguration.class) .run((context) -> assertThat(context).hasSingleBean(Clock.class) .hasSingleBean(WavefrontMeterRegistry.class) .hasSingleBean(WavefrontConfig.class).hasBean("customConfig")); @@ -73,10 +77,8 @@ public class WavefrontMetricsExportAutoConfigurationTests { @Test public void allowsRegistryToBeCustomized() { - this.runner - .withUserConfiguration(CustomRegistryConfiguration.class) - .withPropertyValues( - "management.metrics.export.wavefront.api-token=abcde") + this.runner.withUserConfiguration(CustomRegistryConfiguration.class) + .withPropertyValues("management.metrics.export.wavefront.api-token=abcde") .run((context) -> assertThat(context).hasSingleBean(Clock.class) .hasSingleBean(WavefrontConfig.class) .hasSingleBean(WavefrontMeterRegistry.class) @@ -85,10 +87,8 @@ public class WavefrontMetricsExportAutoConfigurationTests { @Test public void stopsMeterRegistryWhenContextIsClosed() { - this.runner - .withUserConfiguration(BaseConfiguration.class) - .withPropertyValues( - "management.metrics.export.wavefront.api-token=abcde") + this.runner.withUserConfiguration(BaseConfiguration.class) + .withPropertyValues("management.metrics.export.wavefront.api-token=abcde") .run((context) -> { WavefrontMeterRegistry registry = spyOnDisposableBean( WavefrontMeterRegistry.class, context); @@ -115,7 +115,7 @@ public class WavefrontMetricsExportAutoConfigurationTests { static class BaseConfiguration { @Bean - public Clock customClock() { + public Clock clock() { return Clock.SYSTEM; } @@ -147,7 +147,8 @@ public class WavefrontMetricsExportAutoConfigurationTests { static class CustomRegistryConfiguration { @Bean(destroyMethod = "stop") - public WavefrontMeterRegistry customRegistry(WavefrontConfig config, Clock clock) { + public WavefrontMeterRegistry customRegistry(WavefrontConfig config, + Clock clock) { return new WavefrontMeterRegistry(config, clock); } diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 6b30e5aaee..051ee33b31 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1391,10 +1391,11 @@ content into your application. Rather, pick only the properties that you need. management.metrics.export.statsd.polling-frequency=10s # How often gauges will be polled. When a gauge is polled, its value is recalculated and if the value has changed, it is sent to the StatsD server. management.metrics.export.statsd.port=8125 # Port of the StatsD server to receive exported metrics. management.metrics.export.statsd.queue-size=2147483647 # Maximum size of the queue of items waiting to be sent to the StatsD server. - management.metrics.export.wavefront.uri= # Optional custom URI for the Wavefront API or proxy. - management.metrics.export.wavefront.source= # Uniquely identifies the app instance that is publishing metrics to Wavefront. Defaults to the local host name. - management.metrics.export.wavefront.api-token= # Required when publishing directly to the Wavefront API host, otherwise does nothing. - management.metrics.export.wavefront.global-prefix= # Setting a global prefix separates metrics originating from this app's whitebox instrumentation from those originating from other Wavefront integrations. + management.metrics.export.wavefront.api-token= # API token used when publishing metrics directly to the Wavefront API host. + management.metrics.export.wavefront.enabled= # Whether exporting of metrics to this backend is enabled. + management.metrics.export.wavefront.global-prefix= # Global prefix to separate metrics originating from this app's white box instrumentation from those originating from other Wavefront integrations when viewed in the Wavefront UI. + management.metrics.export.wavefront.source= # Unique identifier for the app instance that is the source of metrics being published to Wavefront. Defaults to the local host name. + management.metrics.export.wavefront.uri= # URI to which metrics are published. May represent a Wavefront sidecar or the Wavefront API host. This host could also represent an internal proxy set up in your environment that forwards metrics data to the Wavefront API host. management.metrics.use-global-registry=true # Whether auto-configured MeterRegistry implementations should be bound to the global static registry on Metrics. management.metrics.web.client.max-uri-tags=100 # Maximum number of unique URI tag values allowed. After the max number of tag values is reached, metrics with additional tag values are denied by filter. management.metrics.web.client.record-request-percentiles=false # Whether instrumented requests record percentiles histogram buckets by default.