Use getMaxActiveSessions() in Tomcat metrics

Replace the getMaxActive() call with getMaxActiveSessions().

Fixes gh-1902
pull/1923/head
Phillip Webb 10 years ago
parent 4840d2c88c
commit 0a6c635f5e

@ -24,6 +24,7 @@ import java.util.List;
import org.apache.catalina.Container; import org.apache.catalina.Container;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.Manager; import org.apache.catalina.Manager;
import org.apache.catalina.session.ManagerBase;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.metrics.Metric; import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.context.embedded.EmbeddedServletContainer; import org.springframework.boot.context.embedded.EmbeddedServletContainer;
@ -74,12 +75,18 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
private Collection<Metric<?>> metrics(Manager manager) { private Collection<Metric<?>> metrics(Manager manager) {
List<Metric<?>> metrics = new ArrayList<Metric<?>>(2); List<Metric<?>> metrics = new ArrayList<Metric<?>>(2);
metrics.add(new Metric<Integer>("httpsessions.max", manager.getMaxActive())); if (manager instanceof ManagerBase) {
metrics.add(new Metric<Integer>("httpsessions.active", manager addMetric(metrics, "httpsessions.max",
.getActiveSessions())); ((ManagerBase) manager).getMaxActiveSessions());
}
addMetric(metrics, "httpsessions.active", manager.getActiveSessions());
return metrics; return metrics;
} }
private void addMetric(List<Metric<?>> metrics, String name, Integer value) {
metrics.add(new Metric<Integer>(name, value));
}
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException { throws BeansException {

Loading…
Cancel
Save