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 class
An abstractServletContextListener
which allows you to programmatically inject theMetricRegistry
, rate and duration units, and allowed origin forMetricsServlet
. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
protected String
static final String
static final String
protected String
protected com.fasterxml.jackson.databind.ObjectMapper
static final String
static final String
static final String
protected com.codahale.metrics.MetricRegistry
static final String
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doGet
(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected com.fasterxml.jackson.databind.ObjectWriter
getWriter
(jakarta.servlet.http.HttpServletRequest request) void
init
(jakarta.servlet.ServletConfig config) protected TimeUnit
parseTimeUnit
(String value, TimeUnit defaultValue) protected void
setupMetricsModule
(jakarta.servlet.ServletContext context) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, service, service
Methods 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:
init
in interfacejakarta.servlet.Servlet
- Overrides:
init
in 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:
doGet
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
IOException
-
getWriter
protected com.fasterxml.jackson.databind.ObjectWriter getWriter(jakarta.servlet.http.HttpServletRequest request) -
parseTimeUnit
-