Search in sources :

Example 1 with AdminServlet

use of io.dropwizard.metrics.servlets.AdminServlet in project metrics by dropwizard.

the class ExampleServer method main.

public static void main(String[] args) throws Exception {
    COUNTER_1.inc();
    COUNTER_2.inc();
    final ThreadPool threadPool = new InstrumentedQueuedThreadPool(REGISTRY);
    final Server server = new Server(threadPool);
    final Connector connector = new ServerConnector(server, new InstrumentedConnectionFactory(new HttpConnectionFactory(), REGISTRY.timer("http.connection")));
    server.addConnector(connector);
    final ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/initial");
    context.setAttribute(MetricsServlet.METRICS_REGISTRY, REGISTRY);
    context.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, new HealthCheckRegistry());
    final ServletHolder holder = new ServletHolder(new AdminServlet());
    context.addServlet(holder, "/dingo/*");
    final InstrumentedHandler handler = new InstrumentedHandler(REGISTRY);
    handler.setHandler(context);
    server.setHandler(handler);
    server.start();
    server.join();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) InstrumentedHandler(io.dropwizard.metrics.jetty11.InstrumentedHandler) ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.server.Connector) InstrumentedQueuedThreadPool(io.dropwizard.metrics.jetty11.InstrumentedQueuedThreadPool) AdminServlet(io.dropwizard.metrics.servlets.AdminServlet) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HealthCheckRegistry(com.codahale.metrics.health.HealthCheckRegistry) InstrumentedQueuedThreadPool(io.dropwizard.metrics.jetty11.InstrumentedQueuedThreadPool) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) InstrumentedConnectionFactory(io.dropwizard.metrics.jetty11.InstrumentedConnectionFactory)

Aggregations

HealthCheckRegistry (com.codahale.metrics.health.HealthCheckRegistry)1 InstrumentedConnectionFactory (io.dropwizard.metrics.jetty11.InstrumentedConnectionFactory)1 InstrumentedHandler (io.dropwizard.metrics.jetty11.InstrumentedHandler)1 InstrumentedQueuedThreadPool (io.dropwizard.metrics.jetty11.InstrumentedQueuedThreadPool)1 AdminServlet (io.dropwizard.metrics.servlets.AdminServlet)1 Connector (org.eclipse.jetty.server.Connector)1 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)1 Server (org.eclipse.jetty.server.Server)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 ThreadPool (org.eclipse.jetty.util.thread.ThreadPool)1