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

项目:Poseidon    文件:Poseidon.java   
private ServletContextHandler getMetricsHandler() {
    MetricRegistry registry = Metrics.getRegistry();
    HealthCheckRegistry healthCheckRegistry = Metrics.getHealthCheckRegistry();
    healthCheckRegistry.register("rotation", new Rotation(configuration.getRotationStatusFilePath()));

    registry.registerAll(new GarbageCollectorMetricSet());
    registry.registerAll(new MemoryUsageGaugeSet());
    registry.registerAll(new ThreadStatesGaugeSet());
    registry.registerAll(new JvmAttributeGaugeSet());

    ServletContextHandler servletContextHandler = new ServletContextHandler();
    servletContextHandler.setContextPath("/__metrics");
    servletContextHandler.setAttribute(MetricsServlet.class.getCanonicalName() + ".registry", registry);
    servletContextHandler.setAttribute(HealthCheckServlet.class.getCanonicalName() + ".registry", healthCheckRegistry);
    servletContextHandler.addServlet(new ServletHolder(new AdminServlet()), "/*");

    return servletContextHandler;
}
项目:springJpaKata    文件:MetricsConfig.java   
@Bean
@Autowired
public ServletRegistrationBean servletHealthRegistryBean(HealthCheckRegistry healthCheckRegistry) {
    HealthCheckServlet hc = new HealthCheckServlet(healthCheckRegistry);
    ServletRegistrationBean srb = new ServletRegistrationBean(hc, "/health/*");
    srb.setLoadOnStartup(2);
    return srb;
}
项目:Bionimbuz    文件:MetricsServletContextListener.java   
@Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        servletContextEvent.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthCheckRegistry);
        servletContextEvent.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry);

//            metricRegistry.counter("teste");
    }
项目:springboot-shiro-cas-mybatis    文件:StatisticsController.java   
@Override
public void setServletContext(final ServletContext servletContext) {
    servletContext.setAttribute(MetricsServlet.METRICS_REGISTRY, this.metricsRegistry);
    servletContext.setAttribute(MetricsServlet.SHOW_SAMPLES, Boolean.TRUE);
    servletContext.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, this.healthCheckRegistry);
}
项目:springboot-shiro-cas-mybatis    文件:StatisticsController.java   
@Override
public void setServletContext(final ServletContext servletContext) {
    servletContext.setAttribute(MetricsServlet.METRICS_REGISTRY, this.metricsRegistry);
    servletContext.setAttribute(MetricsServlet.SHOW_SAMPLES, Boolean.TRUE);
    servletContext.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, this.healthCheckRegistry);
}
项目:cas-5.1.0    文件:StatisticsController.java   
@Override
public void setServletContext(final ServletContext servletContext) {
    servletContext.setAttribute(MetricsServlet.METRICS_REGISTRY, this.metricsRegistry);
    servletContext.setAttribute(MetricsServlet.SHOW_SAMPLES, Boolean.TRUE);
    servletContext.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, this.healthCheckRegistry);
}
项目:cas-server-4.2.1    文件:StatisticsController.java   
@Override
public void setServletContext(final ServletContext servletContext) {
    servletContext.setAttribute(MetricsServlet.METRICS_REGISTRY, this.metricsRegistry);
    servletContext.setAttribute(MetricsServlet.SHOW_SAMPLES, Boolean.TRUE);
    servletContext.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, this.healthCheckRegistry);
}
项目: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");
}
项目:cas4.1.9    文件:StatisticsController.java   
@Override
public void setServletContext(final ServletContext servletContext) {
    servletContext.setAttribute(MetricsServlet.METRICS_REGISTRY, this.metricsRegistry);
    servletContext.setAttribute(MetricsServlet.SHOW_SAMPLES, Boolean.TRUE);
    servletContext.setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, this.healthCheckRegistry);
}
项目:chassis    文件:AdminTransportConfiguration.java   
@Bean(initMethod="start", destroyMethod="stop")
@Order(0)
public Server adminServer(
           @Value("${admin.hostname}") String hostname,
           @Value("${admin.port}") int port) {

       // set up servlets
       ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY);
    context.setErrorHandler(null);
    context.setWelcomeFiles(new String[] { "/" });

    // enable gzip
    context.addFilter(GzipFilter.class, "/*", null);

    // add common admin servlets
    context.addServlet(new ServletHolder(new HealthServlet(healthCheckRegistry)), "/healthcheck");
    context.addServlet(new ServletHolder(new ClasspathResourceServlet("com/kixeye/chassis/transport/admin", "/admin/", "index.html")), "/admin/*");
    context.addServlet(new ServletHolder(new PropertiesServlet()), "/admin/properties");
    context.addServlet(new ServletHolder(new ClasspathDumpServlet()), "/admin/classpath");

       // add websocket servlets if WebSockets have been initialized
       if (mappingRegistry != null && messageRegistry != null) {
           context.addServlet(new ServletHolder(new ProtobufMessagesDocumentationServlet(appName, mappingRegistry, messageRegistry)), "/schema/messages/protobuf");
           context.addServlet(new ServletHolder(new ProtobufEnvelopeDocumentationServlet()), "/schema/envelope/protobuf");
       }

       // add metric servlets if Metric has been initialized
       if (metricRegistry != null && healthCheckRegistry != null) {
           context.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry);
           context.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthCheckRegistry);

           ServletHolder holder = new ServletHolder(new AdminServlet());
           holder.setInitParameter("service-name", System.getProperty("app.name"));
           context.addServlet(holder, "/metrics/*");
       }

       // create the server
    InetSocketAddress address = StringUtils.isBlank(hostname) ? new InetSocketAddress(port) : new InetSocketAddress(hostname, port);

    Server server = new Server();

    JettyConnectorRegistry.registerHttpConnector(server, address);
       server.setHandler(context);

    return server;
}
项目:cdk    文件:StartReportingMetricsToHTTPBuilder.java   
public StartReportingMetricsToHTTP(CommandBuilder builder, Config config, Command parent, 
                                   Command child, final MorphlineContext context) {

  super(builder, config, parent, child, context);      

  this.port = getConfigs().getInt(config, "port", 8080);
  final TimeUnit defaultDurationUnit = getConfigs().getTimeUnit(config, "defaultDurationUnit", TimeUnit.MILLISECONDS);
  final TimeUnit defaultRateUnit = getConfigs().getTimeUnit(config, "defaultRateUnit", TimeUnit.SECONDS); 
  validateArguments();

  synchronized (SERVERS) {
    Server server = SERVERS.get(port);
    if (server == null) {
      ServletContextHandler servletContextHandler = new ServletContextHandler();
      servletContextHandler.addServlet(AdminServlet.class, "/*");

      servletContextHandler.addEventListener(new MetricsServlet.ContextListener() {      
        @Override
        protected MetricRegistry getMetricRegistry() {
          return context.getMetricRegistry();
        }
        @Override
        protected TimeUnit getRateUnit() {
          return defaultRateUnit;
        }
        @Override
        protected TimeUnit getDurationUnit() {
          return defaultDurationUnit;
        }
      });

      servletContextHandler.addEventListener(new HealthCheckServlet.ContextListener() {         
        @Override
        protected HealthCheckRegistry getHealthCheckRegistry() {
          return context.getHealthCheckRegistry();
        }
      });

      server = new Server(port);
      server.setHandler(servletContextHandler);

      try {
        server.start();
      } catch (Exception e) {
        throw new MorphlineRuntimeException(e);
      }

      SERVERS.put(port, server);
    }
  }
}
项目:grails-lightweight-deploy    文件:InternalContext.java   
public InternalContext(HealthCheckRegistry healthCheckRegistry, MetricRegistry metricRegistry) {
    super();

    getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthCheckRegistry);
    getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry);
}