public void startServer() throws Exception { if (this.bindAddress != null) { this.server = new Server(new InetSocketAddress(InetAddress.getByName(this.bindAddress), port)); } else { this.server = new Server(this.port); } ServletContextHandler handler = new ServletContextHandler(this.server, pathPrefix); if (metricsRegistries != null) { // TODO: there is a way to wire these up automagically via the AdminServlet, but it escapes me right now handler.addServlet(new ServletHolder(new MetricsServlet(metricsRegistries.metricRegistry)), "/metrics"); handler.addServlet(new ServletHolder(new io.prometheus.client.exporter.MetricsServlet()), "/prometheus"); handler.addServlet(new ServletHolder(new HealthCheckServlet(metricsRegistries.healthCheckRegistry)), "/healthcheck"); handler.addServlet(new ServletHolder(new PingServlet()), "/ping"); } if (diagnosticContext != null) { handler.addServlet(new ServletHolder(new DiagnosticHealthCheck(diagnosticContext)), "/diagnostic"); } this.server.start(); this.server.join(); }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); this.healthCheckServlet = new HealthCheckServlet(); healthCheckServlet.init(config); this.metricsServlet = new MetricsServlet(); metricsServlet.init(config); this.pingServlet = new PingServlet(); pingServlet.init(config); this.threadDumpServlet = new ThreadDumpServlet(); threadDumpServlet.init(config); this.metricsUri = getParam(config.getInitParameter("metrics-uri"), DEFAULT_METRICS_URI); this.pingUri = getParam(config.getInitParameter("ping-uri"), DEFAULT_PING_URI); this.threadsUri = getParam(config.getInitParameter("threads-uri"), DEFAULT_THREADS_URI); this.healthcheckUri = getParam(config.getInitParameter("healthcheck-uri"), DEFAULT_HEALTHCHECK_URI); this.serviceName = getParam(config.getInitParameter("service-name"), null); }
@Activate protected void activate() throws NamespaceException, ServletException { httpService.registerServlet(METRICS_URI, new MetricsServlet(metricRegistry), null, null); httpService.registerServlet(HEALTH_URI, new HealthCheckServlet(healthCheckRegistry), null, null); httpService.registerServlet(PING_URI, new PingServlet(), null, null); httpService.registerServlet(THREADS_URI, new ThreadDumpServlet(), null, null); }
public Map<String, HttpServlet> getServletMappings() { final MetricsServlet metricsServlet = new MetricsServlet(serverConfiguration.getMetricRegistry()); final HealthCheckServlet healthCheckServlet = new HealthCheckServlet(serverConfiguration.getHealthCheckRegistry()); final GearmanServlet gearmanServlet = new GearmanServlet(serverConfiguration.getJobQueueMonitor(), serverConfiguration.getJobManager(), serverConfiguration.getQueueMetrics()); final DashboardServlet dashboardServlet = new DashboardServlet(serverConfiguration.getJobQueueMonitor(), serverConfiguration.getQueueMetrics()); final JobQueueServlet jobQueueServlet = new JobQueueServlet(serverConfiguration.getJobManager()); final ClusterServlet clusterServlet = new ClusterServlet(serverConfiguration); final ExceptionsServlet exceptionsServlet = new ExceptionsServlet(serverConfiguration.getExceptionStorageEngine()); Map<String, HttpServlet> mappings = new HashMap<>(); mappings.put("/gearman/*", gearmanServlet); mappings.put("/queues/*", jobQueueServlet); mappings.put("/metrics/*", metricsServlet); mappings.put("/health/*", healthCheckServlet); mappings.put("/cluster/*", clusterServlet); mappings.put("/exceptions/*", exceptionsServlet); mappings.put("/", dashboardServlet); return mappings; }
serve(SYSTEM_HEALTHCHECK).with(new HealthCheckServlet(monitoring.getHealth())); serve(SYSTEM_METRICS).with(new MetricsServlet(monitoring.getMetrics())); serve(SYSTEM_PING).with(new PingServlet());
serve(SYSTEM_HEALTHCHECK).with(new HealthCheckServlet(monitoring.getHealth())); serve(SYSTEM_METRICS).with(new MetricsServlet(monitoring.getMetrics())); serve(SYSTEM_PING).with(new PingServlet());