Skip to content

Commit 7321259

Browse files
committed
Move Jetty metrics auto-configuration into spring-boot-jetty
1 parent 88feb7d commit 7321259

File tree

13 files changed

+40
-38
lines changed

13 files changed

+40
-38
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ org.springframework.boot.actuate.autoconfigure.metrics.export.statsd.StatsdMetri
3939
org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront.WavefrontMetricsExportAutoConfiguration
4040
org.springframework.boot.actuate.autoconfigure.metrics.jersey.JerseyServerMetricsAutoConfiguration
4141
org.springframework.boot.actuate.autoconfigure.metrics.task.TaskExecutorMetricsAutoConfiguration
42-
org.springframework.boot.actuate.autoconfigure.metrics.web.jetty.JettyMetricsAutoConfiguration
4342
org.springframework.boot.actuate.autoconfigure.metrics.web.tomcat.TomcatMetricsAutoConfiguration
4443
org.springframework.boot.actuate.autoconfigure.observation.batch.BatchObservationAutoConfiguration
4544
org.springframework.boot.actuate.autoconfigure.observation.graphql.GraphQlObservationAutoConfiguration

spring-boot-project/spring-boot-actuator/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ description = "Spring Boot Actuator"
1111
dependencies {
1212
api(project(":spring-boot-project:spring-boot"))
1313
optional(project(":spring-boot-project:spring-boot-http-converter"))
14-
optional(project(":spring-boot-project:spring-boot-jetty"))
1514
optional(project(":spring-boot-project:spring-boot-jsonb"))
1615
optional(project(":spring-boot-project:spring-boot-reactor-netty"))
1716
optional(project(":spring-boot-project:spring-boot-tomcat"))
@@ -37,9 +36,6 @@ dependencies {
3736
optional("org.apache.tomcat.embed:tomcat-embed-core")
3837
optional("org.aspectj:aspectjweaver")
3938
optional("org.eclipse.angus:angus-mail")
40-
optional("org.eclipse.jetty:jetty-server") {
41-
exclude(group: "org.eclipse.jetty.toolchain", module: "jetty-jakarta-servlet-api")
42-
}
4339
optional("org.glassfish.jersey.core:jersey-server")
4440
optional("org.glassfish.jersey.containers:jersey-container-servlet-core")
4541
optional("org.hibernate.validator:hibernate-validator")

spring-boot-project/spring-boot-jetty/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies {
1313
api("org.eclipse.jetty.ee10:jetty-ee10-servlets")
1414
api("org.eclipse.jetty.ee10:jetty-ee10-webapp")
1515
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
16+
optional(project(":spring-boot-project:spring-boot-metrics"))
1617
optional("org.apache.tomcat.embed:tomcat-embed-jasper")
1718
optional("org.eclipse.jetty:jetty-alpn-conscrypt-server")
1819
optional("org.eclipse.jetty.ee10.websocket:jetty-ee10-websocket-jakarta-server")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.metrics.web.jetty;
17+
package org.springframework.boot.jetty.actuate.metrics;
1818

1919
import org.eclipse.jetty.server.Server;
2020

@@ -29,7 +29,7 @@
2929
* Base class for binding Jetty metrics in response to an {@link ApplicationStartedEvent}.
3030
*
3131
* @author Andy Wilkinson
32-
* @since 2.6.0
32+
* @since 4.0.0
3333
*/
3434
public abstract class AbstractJettyMetricsBinder implements ApplicationListener<ApplicationStartedEvent> {
3535

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.metrics.web.jetty;
17+
package org.springframework.boot.jetty.actuate.metrics;
1818

1919
import java.util.Collections;
2020

@@ -27,7 +27,7 @@
2727
* {@link AbstractJettyMetricsBinder} for {@link JettyConnectionMetrics}.
2828
*
2929
* @author Chris Bono
30-
* @since 2.6.0
30+
* @since 4.0.0
3131
*/
3232
public class JettyConnectionMetricsBinder extends AbstractJettyMetricsBinder {
3333

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.metrics.web.jetty;
17+
package org.springframework.boot.jetty.actuate.metrics;
1818

1919
import java.util.Collections;
2020

@@ -28,7 +28,7 @@
2828
* {@link AbstractJettyMetricsBinder} for {@link JettyServerThreadPoolMetrics}.
2929
*
3030
* @author Andy Wilkinson
31-
* @since 2.1.0
31+
* @since 4.0.0
3232
*/
3333
public class JettyServerThreadPoolMetricsBinder extends AbstractJettyMetricsBinder {
3434

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.metrics.web.jetty;
17+
package org.springframework.boot.jetty.actuate.metrics;
1818

1919
import java.util.Collections;
2020

@@ -27,7 +27,7 @@
2727
* {@link AbstractJettyMetricsBinder} for {@link JettySslHandshakeMetrics}.
2828
*
2929
* @author Chris Bono
30-
* @since 2.6.0
30+
* @since 4.0.0
3131
*/
3232
public class JettySslHandshakeMetricsBinder extends AbstractJettyMetricsBinder {
3333

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.metrics.web.jetty;
17+
package org.springframework.boot.jetty.actuate.metrics.autoconfigure;
1818

1919
import io.micrometer.core.instrument.MeterRegistry;
2020
import io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics;
2121
import io.micrometer.core.instrument.binder.jetty.JettyServerThreadPoolMetrics;
2222
import io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics;
2323
import org.eclipse.jetty.server.Server;
2424

25-
import org.springframework.boot.actuate.metrics.web.jetty.JettyConnectionMetricsBinder;
26-
import org.springframework.boot.actuate.metrics.web.jetty.JettyServerThreadPoolMetricsBinder;
27-
import org.springframework.boot.actuate.metrics.web.jetty.JettySslHandshakeMetricsBinder;
2825
import org.springframework.boot.autoconfigure.AutoConfiguration;
2926
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
3027
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3128
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
3229
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3330
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3431
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
32+
import org.springframework.boot.jetty.actuate.metrics.JettyConnectionMetricsBinder;
33+
import org.springframework.boot.jetty.actuate.metrics.JettyServerThreadPoolMetricsBinder;
34+
import org.springframework.boot.jetty.actuate.metrics.JettySslHandshakeMetricsBinder;
3535
import org.springframework.boot.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration;
3636
import org.springframework.context.annotation.Bean;
3737

@@ -40,7 +40,7 @@
4040
*
4141
* @author Andy Wilkinson
4242
* @author Chris Bono
43-
* @since 2.1.0
43+
* @since 4.0.0
4444
*/
4545
@AutoConfiguration(after = CompositeMeterRegistryAutoConfiguration.class)
4646
@ConditionalOnWebApplication
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
/**
1818
* Auto-configuration for Jetty actuator metrics.
1919
*/
20-
package org.springframework.boot.actuate.autoconfigure.metrics.web.jetty;
20+
package org.springframework.boot.jetty.actuate.metrics.autoconfigure;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,4 +17,4 @@
1717
/**
1818
* Actuator support for Jetty metrics.
1919
*/
20-
package org.springframework.boot.actuate.metrics.web.jetty;
20+
package org.springframework.boot.jetty.actuate.metrics;
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
org.springframework.boot.jetty.actuate.metrics.autoconfigure.JettyMetricsAutoConfiguration
12
org.springframework.boot.jetty.autoconfigure.reactive.JettyReactiveWebServerAutoConfiguration
23
org.springframework.boot.jetty.autoconfigure.servlet.JettyServletWebServerAutoConfiguration
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.autoconfigure.metrics.web.jetty;
17+
package org.springframework.boot.jetty.actuate.metrics.autoconfigure;
1818

1919
import io.micrometer.core.instrument.MeterRegistry;
2020
import io.micrometer.core.instrument.Tags;
2121
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
22+
import org.assertj.core.api.Assertions;
2223
import org.junit.jupiter.api.Test;
2324

2425
import org.springframework.boot.SpringApplication;
25-
import org.springframework.boot.actuate.metrics.web.jetty.JettyConnectionMetricsBinder;
26-
import org.springframework.boot.actuate.metrics.web.jetty.JettyServerThreadPoolMetricsBinder;
27-
import org.springframework.boot.actuate.metrics.web.jetty.JettySslHandshakeMetricsBinder;
2826
import org.springframework.boot.autoconfigure.AutoConfigurations;
2927
import org.springframework.boot.context.event.ApplicationStartedEvent;
28+
import org.springframework.boot.jetty.actuate.metrics.JettyConnectionMetricsBinder;
29+
import org.springframework.boot.jetty.actuate.metrics.JettyServerThreadPoolMetricsBinder;
30+
import org.springframework.boot.jetty.actuate.metrics.JettySslHandshakeMetricsBinder;
3031
import org.springframework.boot.jetty.autoconfigure.reactive.JettyReactiveWebServerAutoConfiguration;
3132
import org.springframework.boot.jetty.autoconfigure.servlet.JettyServletWebServerAutoConfiguration;
3233
import org.springframework.boot.jetty.reactive.JettyReactiveWebServerFactory;
@@ -62,7 +63,7 @@ void autoConfiguresThreadPoolMetricsWithEmbeddedServletJetty() {
6263
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
6364
assertThat(context).hasSingleBean(JettyServerThreadPoolMetricsBinder.class);
6465
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
65-
assertThat(registry.find("jetty.threads.config.min").meter()).isNotNull();
66+
Assertions.assertThat(registry.find("jetty.threads.config.min").meter()).isNotNull();
6667
});
6768
}
6869

@@ -75,7 +76,7 @@ void autoConfiguresThreadPoolMetricsWithEmbeddedReactiveJetty() {
7576
.run((context) -> {
7677
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
7778
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
78-
assertThat(registry.find("jetty.threads.config.min").meter()).isNotNull();
79+
Assertions.assertThat(registry.find("jetty.threads.config.min").meter()).isNotNull();
7980
});
8081
}
8182

@@ -97,7 +98,7 @@ void autoConfiguresConnectionMetricsWithEmbeddedServletJetty() {
9798
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
9899
assertThat(context).hasSingleBean(JettyConnectionMetricsBinder.class);
99100
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
100-
assertThat(registry.find("jetty.connections.messages.in").meter()).isNotNull();
101+
Assertions.assertThat(registry.find("jetty.connections.messages.in").meter()).isNotNull();
101102
});
102103
}
103104

@@ -110,7 +111,7 @@ void autoConfiguresConnectionMetricsWithEmbeddedReactiveJetty() {
110111
.run((context) -> {
111112
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
112113
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
113-
assertThat(registry.find("jetty.connections.messages.in").meter()).isNotNull();
114+
Assertions.assertThat(registry.find("jetty.connections.messages.in").meter()).isNotNull();
114115
});
115116
}
116117

@@ -126,9 +127,11 @@ void allowsCustomJettyConnectionMetricsBinderToBeUsed() {
126127
assertThat(context).hasSingleBean(JettyConnectionMetricsBinder.class)
127128
.hasBean("customJettyConnectionMetricsBinder");
128129
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
129-
assertThat(registry.find("jetty.connections.messages.in")
130-
.tag("custom-tag-name", "custom-tag-value")
131-
.meter()).isNotNull();
130+
Assertions
131+
.assertThat(registry.find("jetty.connections.messages.in")
132+
.tag("custom-tag-name", "custom-tag-value")
133+
.meter())
134+
.isNotNull();
132135
});
133136
}
134137

@@ -145,7 +148,7 @@ void autoConfiguresSslHandshakeMetricsWithEmbeddedServletJetty() {
145148
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
146149
assertThat(context).hasSingleBean(JettySslHandshakeMetricsBinder.class);
147150
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
148-
assertThat(registry.find("jetty.ssl.handshakes").meter()).isNotNull();
151+
Assertions.assertThat(registry.find("jetty.ssl.handshakes").meter()).isNotNull();
149152
});
150153
}
151154

@@ -161,7 +164,7 @@ void autoConfiguresSslHandshakeMetricsWithEmbeddedReactiveJetty() {
161164
.run((context) -> {
162165
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
163166
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
164-
assertThat(registry.find("jetty.ssl.handshakes").meter()).isNotNull();
167+
Assertions.assertThat(registry.find("jetty.ssl.handshakes").meter()).isNotNull();
165168
});
166169
}
167170

@@ -180,7 +183,9 @@ void allowsCustomJettySslHandshakeMetricsBinderToBeUsed() {
180183
assertThat(context).hasSingleBean(JettySslHandshakeMetricsBinder.class)
181184
.hasBean("customJettySslHandshakeMetricsBinder");
182185
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
183-
assertThat(registry.find("jetty.ssl.handshakes").tag("custom-tag-name", "custom-tag-value").meter())
186+
Assertions
187+
.assertThat(
188+
registry.find("jetty.ssl.handshakes").tag("custom-tag-name", "custom-tag-value").meter())
184189
.isNotNull();
185190
});
186191

0 commit comments

Comments
 (0)