Java 类com.codahale.metrics.servlets.PingServlet 实例源码

项目:emodb    文件:EmoService.java   
private void evaluateWeb()
        throws Exception {
    if (!runPerServiceMode(web)) {
        return;
    }

    // Load balancers should hit the ping servlet, exposed on the main port to reflect main connection pool issues
    _environment.servlets().addServlet("/ping", new PingServlet());
    // Serve static assets
    _environment.jersey().register(FaviconResource.class);

    // Add a filter to provide finer 5xx metrics than the default DropWizard metrics include.
    //noinspection unchecked
    _environment.jersey().getResourceConfig().getContainerResponseFilters()
            .add(new ServerErrorResponseMetricsFilter(_environment.metrics()));
}
项目:onerepmax    文件:JettyServer.java   
private void registerMetricsServlets(final ServletContextHandler context) {
  context.addEventListener(new ExampleHealthCheckServletContextListener());
  context.addEventListener(new ExampleMetricsServletContextListener());
  context.addServlet(AdminServlet.class, "/admin");
  context.addServlet(HealthCheckServlet.class, "/admin/healthcheck");
  context.addServlet(MetricsServlet.class, "/admin/metrics");
  context.addServlet(PingServlet.class, "/admin/ping");
  context.addServlet(ThreadDumpServlet.class, "/admin/threads");
}
项目:nexus-public    文件:MetricsModule.java   
@Override
protected void configure() {
  // NOTE: AdminServletModule (metrics-guice integration) generates invalid links, so wire up servlets ourselves

  final Clock clock = Clock.defaultClock();
  bind(Clock.class).toInstance(clock);

  final JsonFactory jsonFactory = new JsonFactory(new ObjectMapper());
  bind(JsonFactory.class).toInstance(jsonFactory);

  install(new ServletModule()
  {
    @Override
    protected void configureServlets() {
      bind(MetricsServlet.class);
      bind(HealthCheckServlet.class);

      serve(MOUNT_POINT + "/ping").with(new PingServlet());
      serve(MOUNT_POINT + "/threads").with(new ThreadDumpServlet());
      serve(MOUNT_POINT + "/data").with(MetricsServlet.class);
      serve(MOUNT_POINT + "/healthcheck").with(HealthCheckServlet.class);

      // record metrics for all webapp access
      filter("/*").through(new InstrumentedFilter());

      bind(SecurityFilter.class);

      // configure security
      filter(MOUNT_POINT + "/*").through(SecurityFilter.class);
    }
  });

  // require permission to use endpoints
  install(new FilterChainModule()
  {
    @Override
    protected void configure() {
      addFilterChain(MOUNT_POINT + "/**",
          NexusAuthenticationFilter.NAME,
          AnonymousFilter.NAME,
          PermissionsFilter.config("nexus:metrics:read"));
    }
  });

  log.info("Metrics support configured");
}