Add Jetty's ThreadPool metrics #593
Conversation
.tags(tags) | ||
.description("The number of max threads") | ||
.register(registry); | ||
Gauge.builder("jetty.threads.live", threadPool, InstrumentedQueuedThreadPool::getThreads) |
checketts
May 7, 2018
•
Collaborator
How does this compare to the Tomcat equivalent? Wondering if active
is a better name and how it differs from busy? Or is it merely idle + busy
?
How does this compare to the Tomcat equivalent? Wondering if active
is a better name and how it differs from busy? Or is it merely idle + busy
?
matsumana
May 8, 2018
Author
Contributor
I decided the name live
with reference to JvmThreadMetrics.
https://github.com/micrometer-metrics/micrometer/blob/v1.0.3/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/JvmThreadMetrics.java#L57
For the meaning of the metric please refer to the Jetty's source.
https://github.com/eclipse/jetty.project/blob/jetty-9.4.8.v20171121/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java#L428-L455
I decided the name live
with reference to JvmThreadMetrics.
https://github.com/micrometer-metrics/micrometer/blob/v1.0.3/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/JvmThreadMetrics.java#L57
For the meaning of the metric please refer to the Jetty's source.
https://github.com/eclipse/jetty.project/blob/jetty-9.4.8.v20171121/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java#L428-L455
matsumana
May 8, 2018
Author
Contributor
Unified with Tomcat's metrics name.
(from live
to current
)
https://github.com/micrometer-metrics/micrometer/blob/v1.0.3/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/tomcat/TomcatMetrics.java#L89
Unified with Tomcat's metrics name.
(from live
to current
)
https://github.com/micrometer-metrics/micrometer/blob/v1.0.3/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/tomcat/TomcatMetrics.java#L89
Hello. |
Just a thought: Is the |
Good point.
|
Updated |
Just tested against Spring Boot 1.5 with
LGTM. Perhaps some auto-configuration for |
@mweirauch Thank you for the confirmation. |
Would you merge this PR? |
Just one thing, could you add I am not too familiar with the Anything else @checketts @jkschneider ? Rebase against |
f89ff6f
into
micrometer-metrics:master
Merged in 21a375a |
I fear the Haven't found any other solution except actually defining the factory ourselfs. Dunno if the setup has changed with Spring Boot 2 and it becomes easier. In case one really needs to roll his own factory and still wants threadpool instrumentation, one needs to exclude the |
@mweirauch Thank you for the opinion. |
The factory is being asked to create a server before our configuration has a chance to kick in. Relates to #593.
The factory is being asked to create a server before our configuration has a chance to kick in. Relates to #593.
I'm looking at incorporating this change into Spring Boot 2.0. What's the benefit of |
So, perhaps we could actually ask for the Would it be allowed to register a new bean within Edit: Think we could just directly bind to the |
Not really, no. A |
How does this look like? @Configuration
@ConditionalOnClass({ Server.class, Loader.class, WebAppContext.class })
public class JettyMetricsAutoConfiguration {
@Bean
public WebServerFactoryCustomizer<JettyServletWebServerFactory> jettyFactoryCustomizer(
MeterRegistry registry) {
return (factory) -> factory.setThreadPool(
new InstrumentedQueuedThreadPool(registry, Collections.emptyList()));
}
} |
That's better in terms of the conditions, but it's still setting the factory's thread pool and using |
I've opened #911 to describe and further discuss what I think needs to be done. |
I want to monitor whether Jetty's ThreadPool setting is sufficient so I'd like to add several metrics.
Usage
Example In Spring Boot 2.0.x