Created
August 13, 2016 17:56
-
-
Save ivanursul/e8301df33eebd9a2d3631db7f5cb0e8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.startup.queue.metrics; | |
import com.codahale.metrics.MetricRegistry; | |
import com.codahale.metrics.health.HealthCheckRegistry; | |
import com.codahale.metrics.servlets.HealthCheckServlet; | |
import com.codahale.metrics.servlets.MetricsServlet; | |
import javax.servlet.ServletContextEvent; | |
import javax.servlet.ServletContextListener; | |
public class MetricsServletContextListener implements ServletContextListener { | |
private MetricRegistry metricRegistry; | |
private HealthCheckRegistry healthCheckRegistry; | |
public MetricsServletContextListener(MetricRegistry metricRegistry, HealthCheckRegistry healthCheckRegistry) { | |
this.metricRegistry = metricRegistry; | |
this.healthCheckRegistry = healthCheckRegistry; | |
} | |
@Override | |
public void contextInitialized(ServletContextEvent servletContextEvent) { | |
servletContextEvent.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY,healthCheckRegistry); | |
servletContextEvent.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry); | |
} | |
@Override | |
public void contextDestroyed(ServletContextEvent sce) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment