Java Jetty metrics doesn't look correct

379 views
Skip to first unread message

mben...@thoughtworks.com

unread,
Jul 5, 2018, 5:10:10 AM7/5/18
to Prometheus Users
Hey all,


we are using https://github.com/prometheus/client_java/tree/master/simpleclient_jetty with spring boot, our integration look like this. 



@Bean
public EmbeddedServletContainerCustomizer jettyCustomizer(EmbeddedWebApplicationContext context) {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer factory) {
Assert.state(factory instanceof JettyEmbeddedServletContainerFactory, "Use Jetty for this server");
JettyEmbeddedServletContainerFactory jettyFactory = (JettyEmbeddedServletContainerFactory) factory;
jettyFactory.addServerCustomizers(new JettyServerCustomizer() {
@Override
public void customize(org.eclipse.jetty.server.Server server) {
StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(server.getHandler());
server.setHandler(stats);
new JettyStatisticsCollector(stats).register();
}
});
}
};
}

However, when graphing the jetty_request_count we noticed that the number doesn't add up and that this later report why less number than other metrics that we had and we were looking to replace, and when we started looking at the code of Jetty StatisticsCollector we noticed that in Jetty the counter doesn't have same semantics as in Prometheus, precisely in Jetty a counter is decremented too https://github.com/eclipse/jetty.project/blob/a3100e02118fca25358c8b59baea9bd95b86e92f/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java#L199.

So we were wondering if anyone uses Jetty metrics or are aware as to why we may see different data, and if our analyzes is correct.

Thank you.

Brian Brazil

unread,
Jul 5, 2018, 5:42:31 AM7/5/18
to mben...@thoughtworks.com, Prometheus Users
On 5 July 2018 at 10:10, <mben...@thoughtworks.com> wrote:
Hey all,


we are using https://github.com/prometheus/client_java/tree/master/simpleclient_jetty with spring boot, our integration look like this. 



@Bean
public EmbeddedServletContainerCustomizer jettyCustomizer(EmbeddedWebApplicationContext context) {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer factory) {
Assert.state(factory instanceof JettyEmbeddedServletContainerFactory, "Use Jetty for this server");
JettyEmbeddedServletContainerFactory jettyFactory = (JettyEmbeddedServletContainerFactory) factory;
jettyFactory.addServerCustomizers(new JettyServerCustomizer() {
@Override
public void customize(org.eclipse.jetty.server.Server server) {
StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(server.getHandler());
server.setHandler(stats);
new JettyStatisticsCollector(stats).register();
}
});
}
};
}

However, when graphing the jetty_request_count

There's no such metric, are you sure you're looking at the right one?

Brian
 
we noticed that the number doesn't add up and that this later report why less number than other metrics that we had and we were looking to replace, and when we started looking at the code of Jetty StatisticsCollector we noticed that in Jetty the counter doesn't have same semantics as in Prometheus, precisely in Jetty a counter is decremented too https://github.com/eclipse/jetty.project/blob/a3100e02118fca25358c8b59baea9bd95b86e92f/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java#L199.

So we were wondering if anyone uses Jetty metrics or are aware as to why we may see different data, and if our analyzes is correct.

Thank you.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/cd6a2536-d7cd-496b-9755-99bdaf123bb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Mouad Benchchaoui

unread,
Jul 5, 2018, 5:45:19 AM7/5/18
to Brian Brazil, Prometheus Users

Brian Brazil

unread,
Jul 5, 2018, 5:49:26 AM7/5/18
to Mouad Benchchaoui, Prometheus Users
The code looks okay to me. The CounterStatistic is a combined Counter and active Gauge.

Brian



--
Reply all
Reply to author
Forward
0 new messages