org.eclipse.jetty.servlet.ServletHolder$1: javax.servlet.ServletException: Couldn't find a HealthCheckRegistry instance.I add the servlet like this:
Right now I'm creating the metric registry and the healthcheckregistry as a static field in my main class.
final static MetricRegistry metricRegistry = new MetricRegistry("defaultMetricRegistry");
final static HealthCheckRegistry healthCheckRegistry = new HealthCheckRegistry();
"If the servlet context has an attributed named com.codahale.metrics.servlet.HealthCheckServlet.registry which is aHealthCheckRegistry, HealthCheckServlet will use that instead of the default HealthCheckRegistry."
--
You received this message because you are subscribed to the Google Groups "metrics-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metrics-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "metrics-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metrics-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Cool, I will submit it as a pull request :). Would you prefer me to create an issue on github and then link my pull request, or just send the pull request? I will assume the latter, but let me know if that's not cool.--paul
--
You received this message because you are subscribed to the Google Groups "metrics-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metrics-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
_server = new Server(_port);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
resourceHandler.setResourceBase(".");
HandlerList handlers = new HandlerList();
ServletContextHandler guiceHandler = new ServletContextHandler();
ServletContextHandler metricsContextHandler = new ServletContextHandler();
metricsContextHandler.setContextPath("/one/metrics");
metricsContextHandler.addEventListener(new MyMetricsServletContextListener(_metricRegistry));
metricsContextHandler.addServlet(MetricsServlet.class, "/registry");
guiceHandler.setContextPath("/one/id");
try {
FilterHolder guiceFilter = new FilterHolder(_filter);
guiceHandler.addFilter(guiceFilter, "/*", EnumSet.allOf(DispatcherType.class));
handlers.setHandlers(new Handler[]{metricsContextHandler, guiceHandler, resourceHandler});
_server.setHandler(handlers);
_server.setDumpAfterStart(true);
_server.start();
}catch(Exception ex) {
log.error("Error starting http server", ex);
throw new RuntimeException(ex);
}private static class MyMetricsServletContextListener extends MetricsServlet.ContextListener {
private MetricRegistry _metricRegistry;
public MyMetricsServletContextListener(MetricRegistry metricRegistry) {
_metricRegistry = metricRegistry;
}
@Override
protected MetricRegistry getMetricRegistry() {
return _metricRegistry;
}
}