Merge pull request #26135 from izeye

* pr/26135:
  Polish

Closes gh-26135
This commit is contained in:
Stephane Nicoll 2021-04-15 16:31:25 +02:00
commit 182b75a1fd
11 changed files with 16 additions and 21 deletions

View File

@ -93,7 +93,7 @@ public class MongoMetricsAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
MongoConnectionPoolTagsProvider mongoMetricsConnectionPoolTagsProvider() { MongoConnectionPoolTagsProvider mongoConnectionPoolTagsProvider() {
return new DefaultMongoConnectionPoolTagsProvider(); return new DefaultMongoConnectionPoolTagsProvider();
} }

View File

@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Phillip Webb * @author Phillip Webb
*/ */
public class RepositoryMetricsAutoConfigurationIntegrationTests { class RepositoryMetricsAutoConfigurationIntegrationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple()) private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple())
.withConfiguration( .withConfiguration(

View File

@ -28,7 +28,6 @@ import io.micrometer.core.instrument.distribution.HistogramSnapshot;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
import org.springframework.boot.actuate.autoconfigure.metrics.web.TestController;
import org.springframework.boot.actuate.metrics.AutoTimer; import org.springframework.boot.actuate.metrics.AutoTimer;
import org.springframework.boot.actuate.metrics.data.DefaultRepositoryTagsProvider; import org.springframework.boot.actuate.metrics.data.DefaultRepositoryTagsProvider;
import org.springframework.boot.actuate.metrics.data.MetricsRepositoryMethodInvocationListener; import org.springframework.boot.actuate.metrics.data.MetricsRepositoryMethodInvocationListener;
@ -93,8 +92,8 @@ class RepositoryMetricsAutoConfigurationTests {
@Test @Test
void metricNameCanBeConfigured() { void metricNameCanBeConfigured() {
this.contextRunner.withUserConfiguration(TestController.class) this.contextRunner.withPropertyValues("management.metrics.data.repository.metric-name=datarepo")
.withPropertyValues("management.metrics.data.repository.metric-name=datarepo").run((context) -> { .run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context, ExampleRepository.class); MeterRegistry registry = getInitializedMeterRegistry(context, ExampleRepository.class);
Timer timer = registry.get("datarepo").timer(); Timer timer = registry.get("datarepo").timer();
assertThat(timer).isNotNull(); assertThat(timer).isNotNull();
@ -103,11 +102,8 @@ class RepositoryMetricsAutoConfigurationTests {
@Test @Test
void autoTimeRequestsCanBeConfigured() { void autoTimeRequestsCanBeConfigured() {
this.contextRunner.withUserConfiguration(TestController.class) this.contextRunner.withPropertyValues("management.metrics.data.repository.autotime.enabled=true",
.withPropertyValues("management.metrics.data.repository.autotime.enabled=true", "management.metrics.data.repository.autotime.percentiles=0.5,0.7").run((context) -> {
"management.metrics.data.repository.autotime.percentiles=0.5,0.7",
"management.metrics.data.repository.autotime.percentiles-histogram=true")
.run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context, ExampleRepository.class); MeterRegistry registry = getInitializedMeterRegistry(context, ExampleRepository.class);
Timer timer = registry.get("spring.data.repository.invocations").timer(); Timer timer = registry.get("spring.data.repository.invocations").timer();
HistogramSnapshot snapshot = timer.takeSnapshot(); HistogramSnapshot snapshot = timer.takeSnapshot();
@ -130,7 +126,7 @@ class RepositoryMetricsAutoConfigurationTests {
} }
private MeterRegistry getInitializedMeterRegistry(AssertableApplicationContext context, private MeterRegistry getInitializedMeterRegistry(AssertableApplicationContext context,
Class<?> repositoryInterface) throws Exception { Class<?> repositoryInterface) {
MetricsRepositoryMethodInvocationListener listener = context MetricsRepositoryMethodInvocationListener listener = context
.getBean(MetricsRepositoryMethodInvocationListener.class); .getBean(MetricsRepositoryMethodInvocationListener.class);
ReflectionUtils.doWithLocalMethods(repositoryInterface, (method) -> { ReflectionUtils.doWithLocalMethods(repositoryInterface, (method) -> {

View File

@ -36,13 +36,13 @@ import org.springframework.util.ConcurrentReferenceHashMap;
*/ */
public final class TimedAnnotations { public final class TimedAnnotations {
private static Map<AnnotatedElement, Set<Timed>> cache = new ConcurrentReferenceHashMap<>(); private static final Map<AnnotatedElement, Set<Timed>> cache = new ConcurrentReferenceHashMap<>();
private TimedAnnotations() { private TimedAnnotations() {
} }
/** /**
* Return {@link Timed} annotation that should be used for the given {@code method} * Return {@link Timed} annotations that should be used for the given {@code method}
* and {@code type}. * and {@code type}.
* @param method the source method * @param method the source method
* @param type the source type * @param type the source type

View File

@ -380,7 +380,7 @@ public class ServerProperties {
/** /**
* Maximum number of HTTP requests that can be pipelined before the connection is * Maximum number of HTTP requests that can be pipelined before the connection is
* closed. When set to 0 or 1, keep-alive and pipelining are disabled. When set to * closed. When set to 0 or 1, keep-alive and pipelining are disabled. When set to
* -1, an unlimited number of pipelined or keep-alive requests is allowed. * -1, an unlimited number of pipelined or keep-alive requests are allowed.
*/ */
private int maxKeepAliveRequests = 100; private int maxKeepAliveRequests = 100;

View File

@ -227,7 +227,6 @@ class ServerPropertiesTests {
@Test @Test
void testCustomizeTomcatKeepAliveTimeoutWithInfinite() { void testCustomizeTomcatKeepAliveTimeoutWithInfinite() {
bind("server.tomcat.keep-alive-timeout", "-1"); bind("server.tomcat.keep-alive-timeout", "-1");
assertThat(this.properties.getTomcat().getKeepAliveTimeout().toMillis()).isEqualTo(-1);
assertThat(this.properties.getTomcat().getKeepAliveTimeout()).hasMillis(-1); assertThat(this.properties.getTomcat().getKeepAliveTimeout()).hasMillis(-1);
} }

View File

@ -2154,7 +2154,7 @@ The following JVM metrics are provided:
[[production-ready-metrics-system]] [[production-ready-metrics-system]]
==== System Metrics ==== System Metrics
Auto-configuration will enable system metrics using core Micrometer classes. Auto-configuration will enable system metrics using core Micrometer classes.
System are published under the `system.` and `process.` meter names. System metrics are published under the `system.` and `process.` meter names.
The following system metrics are provided: The following system metrics are provided:

View File

@ -567,7 +567,7 @@ If `spring.config.location` contains directories (as opposed to files), they mus
At runtime they will be appended with the names generated from `spring.config.name` before being loaded. At runtime they will be appended with the names generated from `spring.config.name` before being loaded.
If `spring.config.location` contains files, they are used as-is. If `spring.config.location` contains files, they are used as-is.
Whether specified directly or contained in a directory, files references must include a file extension in their name. Whether specified directly or contained in a directory, file references must include a file extension in their name.
Typical extensions that are supported out-of-the-box are `.properties`, `.yaml`, and `.yml`. Typical extensions that are supported out-of-the-box are `.properties`, `.yaml`, and `.yml`.
When multiple locations are specified, the later ones can override the values of earlier ones. When multiple locations are specified, the later ones can override the values of earlier ones.

View File

@ -151,9 +151,9 @@ class CloudPlatformTests {
} }
@Test @Test
void getActiveWhenHasWebsitesEnableAppServiceStorageAndNoWebsiteNameShouldNotReturnAzureAppService() { void getActiveWhenHasWebsitesEnableAppServiceStorageAndNoWebsiteSiteNameShouldNotReturnAzureAppService() {
Environment environment = getEnvironmentWithEnvVariables( Environment environment = getEnvironmentWithEnvVariables(
Collections.singletonMap("WEBSITES_ENABLE_APP_SERVICE_STORAGE", "---")); Collections.singletonMap("WEBSITES_ENABLE_APP_SERVICE_STORAGE", "false"));
CloudPlatform platform = CloudPlatform.getActive(environment); CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isNull(); assertThat(platform).isNull();
} }