Package io.dropwizard.metrics5.servlets
Class MetricsServlet.ContextListener
java.lang.Object
io.dropwizard.metrics5.servlets.MetricsServlet.ContextListener
- All Implemented Interfaces:
EventListener,javax.servlet.ServletContextListener
- Enclosing class:
- MetricsServlet
public abstract static class MetricsServlet.ContextListener extends Object implements javax.servlet.ServletContextListener
An abstract
ServletContextListener which allows you to programmatically inject the
MetricRegistry, rate and duration units, and allowed origin for
MetricsServlet.-
Constructor Summary
Constructors Constructor Description ContextListener() -
Method Summary
Modifier and Type Method Description voidcontextDestroyed(javax.servlet.ServletContextEvent event)voidcontextInitialized(javax.servlet.ServletContextEvent event)protected StringgetAllowedOrigin()protected TimeUnitgetDurationUnit()protected StringgetJsonpCallbackParameter()Returns the name of the parameter used to specify the jsonp callback, if any.protected io.dropwizard.metrics5.MetricFiltergetMetricFilter()Returns theMetricFilterthat shall be used to filter metrics, orMetricFilter.ALLif the default should be used.protected abstract io.dropwizard.metrics5.MetricRegistrygetMetricRegistry()protected TimeUnitgetRateUnit()
-
Constructor Details
-
ContextListener
public ContextListener()
-
-
Method Details
-
getMetricRegistry
protected abstract io.dropwizard.metrics5.MetricRegistry getMetricRegistry()- Returns:
- the
MetricRegistryto inject into the servlet context.
-
getRateUnit
- Returns:
- the
TimeUnitto which rates should be converted, ornullif the default should be used.
-
getDurationUnit
- Returns:
- the
TimeUnitto which durations should be converted, ornullif the default should be used.
-
getAllowedOrigin
- Returns:
- the
Access-Control-Allow-Originheader value, if any.
-
getJsonpCallbackParameter
Returns the name of the parameter used to specify the jsonp callback, if any. -
getMetricFilter
protected io.dropwizard.metrics5.MetricFilter getMetricFilter()Returns theMetricFilterthat shall be used to filter metrics, orMetricFilter.ALLif the default should be used. -
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent event)- Specified by:
contextInitializedin interfacejavax.servlet.ServletContextListener
-
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent event)- Specified by:
contextDestroyedin interfacejavax.servlet.ServletContextListener
-