mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge pull request #26135 from izeye
* pr/26135: Polish Closes gh-26135
This commit is contained in:
commit
182b75a1fd
@ -86,7 +86,7 @@ dependencies {
|
||||
optional("org.mongodb:mongodb-driver-reactivestreams")
|
||||
optional("org.mongodb:mongodb-driver-sync")
|
||||
optional("org.neo4j.driver:neo4j-java-driver")
|
||||
optional("org.quartz-scheduler:quartz")
|
||||
optional("org.quartz-scheduler:quartz")
|
||||
optional("org.springframework:spring-jdbc")
|
||||
optional("org.springframework:spring-jms")
|
||||
optional("org.springframework:spring-messaging")
|
||||
|
@ -93,7 +93,7 @@ public class MongoMetricsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
MongoConnectionPoolTagsProvider mongoMetricsConnectionPoolTagsProvider() {
|
||||
MongoConnectionPoolTagsProvider mongoConnectionPoolTagsProvider() {
|
||||
return new DefaultMongoConnectionPoolTagsProvider();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class RepositoryMetricsAutoConfigurationIntegrationTests {
|
||||
class RepositoryMetricsAutoConfigurationIntegrationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple())
|
||||
.withConfiguration(
|
||||
|
@ -28,7 +28,6 @@ import io.micrometer.core.instrument.distribution.HistogramSnapshot;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
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.data.DefaultRepositoryTagsProvider;
|
||||
import org.springframework.boot.actuate.metrics.data.MetricsRepositoryMethodInvocationListener;
|
||||
@ -93,8 +92,8 @@ class RepositoryMetricsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void metricNameCanBeConfigured() {
|
||||
this.contextRunner.withUserConfiguration(TestController.class)
|
||||
.withPropertyValues("management.metrics.data.repository.metric-name=datarepo").run((context) -> {
|
||||
this.contextRunner.withPropertyValues("management.metrics.data.repository.metric-name=datarepo")
|
||||
.run((context) -> {
|
||||
MeterRegistry registry = getInitializedMeterRegistry(context, ExampleRepository.class);
|
||||
Timer timer = registry.get("datarepo").timer();
|
||||
assertThat(timer).isNotNull();
|
||||
@ -103,11 +102,8 @@ class RepositoryMetricsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void autoTimeRequestsCanBeConfigured() {
|
||||
this.contextRunner.withUserConfiguration(TestController.class)
|
||||
.withPropertyValues("management.metrics.data.repository.autotime.enabled=true",
|
||||
"management.metrics.data.repository.autotime.percentiles=0.5,0.7",
|
||||
"management.metrics.data.repository.autotime.percentiles-histogram=true")
|
||||
.run((context) -> {
|
||||
this.contextRunner.withPropertyValues("management.metrics.data.repository.autotime.enabled=true",
|
||||
"management.metrics.data.repository.autotime.percentiles=0.5,0.7").run((context) -> {
|
||||
MeterRegistry registry = getInitializedMeterRegistry(context, ExampleRepository.class);
|
||||
Timer timer = registry.get("spring.data.repository.invocations").timer();
|
||||
HistogramSnapshot snapshot = timer.takeSnapshot();
|
||||
@ -130,7 +126,7 @@ class RepositoryMetricsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
private MeterRegistry getInitializedMeterRegistry(AssertableApplicationContext context,
|
||||
Class<?> repositoryInterface) throws Exception {
|
||||
Class<?> repositoryInterface) {
|
||||
MetricsRepositoryMethodInvocationListener listener = context
|
||||
.getBean(MetricsRepositoryMethodInvocationListener.class);
|
||||
ReflectionUtils.doWithLocalMethods(repositoryInterface, (method) -> {
|
||||
|
@ -48,7 +48,7 @@ dependencies {
|
||||
optional("org.mongodb:mongodb-driver-reactivestreams")
|
||||
optional("org.mongodb:mongodb-driver-sync")
|
||||
optional("org.neo4j.driver:neo4j-java-driver")
|
||||
optional("org.quartz-scheduler:quartz")
|
||||
optional("org.quartz-scheduler:quartz")
|
||||
optional("org.springframework:spring-jdbc")
|
||||
optional("org.springframework:spring-messaging")
|
||||
optional("org.springframework:spring-webflux")
|
||||
|
@ -36,13 +36,13 @@ import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
*/
|
||||
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() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
* @param method the source method
|
||||
* @param type the source type
|
||||
|
@ -380,7 +380,7 @@ public class ServerProperties {
|
||||
/**
|
||||
* 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
|
||||
* -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;
|
||||
|
||||
|
@ -227,7 +227,6 @@ class ServerPropertiesTests {
|
||||
@Test
|
||||
void testCustomizeTomcatKeepAliveTimeoutWithInfinite() {
|
||||
bind("server.tomcat.keep-alive-timeout", "-1");
|
||||
assertThat(this.properties.getTomcat().getKeepAliveTimeout().toMillis()).isEqualTo(-1);
|
||||
assertThat(this.properties.getTomcat().getKeepAliveTimeout()).hasMillis(-1);
|
||||
}
|
||||
|
||||
|
@ -2154,7 +2154,7 @@ The following JVM metrics are provided:
|
||||
[[production-ready-metrics-system]]
|
||||
==== System Metrics
|
||||
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:
|
||||
|
||||
|
@ -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.
|
||||
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`.
|
||||
|
||||
When multiple locations are specified, the later ones can override the values of earlier ones.
|
||||
|
@ -151,9 +151,9 @@ class CloudPlatformTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getActiveWhenHasWebsitesEnableAppServiceStorageAndNoWebsiteNameShouldNotReturnAzureAppService() {
|
||||
void getActiveWhenHasWebsitesEnableAppServiceStorageAndNoWebsiteSiteNameShouldNotReturnAzureAppService() {
|
||||
Environment environment = getEnvironmentWithEnvVariables(
|
||||
Collections.singletonMap("WEBSITES_ENABLE_APP_SERVICE_STORAGE", "---"));
|
||||
Collections.singletonMap("WEBSITES_ENABLE_APP_SERVICE_STORAGE", "false"));
|
||||
CloudPlatform platform = CloudPlatform.getActive(environment);
|
||||
assertThat(platform).isNull();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user