com.yammer.metrics.reporting.MetricsServlet Java Examples

The following examples show how to use com.yammer.metrics.reporting.MetricsServlet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaHttpMetricsServer.java    From kafka-http-metrics-reporter with Apache License 2.0 5 votes vote down vote up
/**
 * Method: init
 * Purpose: Initializes the embedded Jetty Server with including the metrics servlets.
 */
private void init() {
    LOG.info("Initializing Kafka Http Metrics Reporter");

    // creating the socket address for binding to the specified address and port
    InetSocketAddress inetSocketAddress = new InetSocketAddress(bindAddress, port);

    // create new Jetty server
    server = new Server(inetSocketAddress);

    // creating the servlet context handler
    ServletContextHandler servletContextHandler = new ServletContextHandler();

    // setting the context path
    servletContextHandler.setContextPath("/");

    // adding the codahale metrics servlet to the servlet context
    servletContextHandler.addServlet(new ServletHolder(new AdminServlet()), "/api");
    servletContextHandler.addServlet(new ServletHolder(new MetricsServlet()), "/api/metrics");
    servletContextHandler.addServlet(new ServletHolder(new ThreadDumpServlet()), "/api/threads");
    servletContextHandler.addServlet(new ServletHolder(new HealthCheckServlet()), "/api/healthcheck");
    servletContextHandler.addServlet(new ServletHolder(new PingServlet()), "/api/ping");

    // adding the configured servlet context handler to the Jetty Server
    server.setHandler(servletContextHandler);
    LOG.info("Finished initializing Kafka Http Metrics Reporter");
}