Package io.dropwizard.metrics.servlets
Class MetricsServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
io.dropwizard.metrics.servlets.MetricsServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
public class MetricsServlet
extends jakarta.servlet.http.HttpServlet
A servlet which returns the metrics in a given registry as an
application/json response.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn abstractServletContextListenerwhich allows you to programmatically inject theMetricRegistry, rate and duration units, and allowed origin forMetricsServlet. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected Stringstatic final Stringstatic final Stringprotected Stringprotected com.fasterxml.jackson.databind.ObjectMapperstatic final Stringstatic final Stringstatic final Stringprotected com.codahale.metrics.MetricRegistrystatic final StringFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected com.fasterxml.jackson.databind.ObjectWritergetWriter(jakarta.servlet.http.HttpServletRequest request) voidinit(jakarta.servlet.ServletConfig config) protected TimeUnitparseTimeUnit(String value, TimeUnit defaultValue) protected voidsetupMetricsModule(jakarta.servlet.ServletContext context) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
RATE_UNIT
-
DURATION_UNIT
-
SHOW_SAMPLES
-
METRICS_REGISTRY
-
ALLOWED_ORIGIN
-
METRIC_FILTER
-
CALLBACK_PARAM
-
allowedOrigin
-
jsonpParamName
-
registry
protected transient com.codahale.metrics.MetricRegistry registry -
mapper
protected transient com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Constructor Details
-
MetricsServlet
public MetricsServlet() -
MetricsServlet
public MetricsServlet(com.codahale.metrics.MetricRegistry registry)
-
-
Method Details
-
init
public void init(jakarta.servlet.ServletConfig config) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Servlet- Overrides:
initin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletException
-
setupMetricsModule
protected void setupMetricsModule(jakarta.servlet.ServletContext context) -
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
getWriter
protected com.fasterxml.jackson.databind.ObjectWriter getWriter(jakarta.servlet.http.HttpServletRequest request) -
parseTimeUnit
-