Package com.codahale.metrics.jersey2
Class InstrumentedResourceMethodApplicationListener
- java.lang.Object
-
- com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener
-
- All Implemented Interfaces:
org.glassfish.jersey.server.model.ModelProcessor
,org.glassfish.jersey.server.monitoring.ApplicationEventListener
@Provider public class InstrumentedResourceMethodApplicationListener extends Object implements org.glassfish.jersey.server.monitoring.ApplicationEventListener, org.glassfish.jersey.server.model.ModelProcessor
An application event listener that listens for Jersey application initialization to be finished, then creates a map of resource method that have metrics annotations.Finally, it listens for method start events, and returns a
RequestEventListener
that updates the relevant metric for suitably annotated methods when it gets the request events indicating that the method is about to be invoked, or just got done being invoked.
-
-
Constructor Summary
Constructors Constructor Description InstrumentedResourceMethodApplicationListener(MetricRegistry metrics)
Construct an application event listener using the given metrics registry.InstrumentedResourceMethodApplicationListener(MetricRegistry metrics, Clock clock, boolean trackFilters)
Constructs a custom application listener.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static String
chooseName(String explicitName, boolean absolute, org.glassfish.jersey.server.model.ResourceMethod method, String... suffixes)
void
onEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent event)
org.glassfish.jersey.server.monitoring.RequestEventListener
onRequest(org.glassfish.jersey.server.monitoring.RequestEvent event)
org.glassfish.jersey.server.model.ResourceModel
processResourceModel(org.glassfish.jersey.server.model.ResourceModel resourceModel, javax.ws.rs.core.Configuration configuration)
org.glassfish.jersey.server.model.ResourceModel
processSubResource(org.glassfish.jersey.server.model.ResourceModel subResourceModel, javax.ws.rs.core.Configuration configuration)
-
-
-
Constructor Detail
-
InstrumentedResourceMethodApplicationListener
public InstrumentedResourceMethodApplicationListener(MetricRegistry metrics)
Construct an application event listener using the given metrics registry.When using this constructor, the
InstrumentedResourceMethodApplicationListener
should be added to a JerseyResourceConfig
as a singleton.- Parameters:
metrics
- aMetricRegistry
-
InstrumentedResourceMethodApplicationListener
public InstrumentedResourceMethodApplicationListener(MetricRegistry metrics, Clock clock, boolean trackFilters)
Constructs a custom application listener.- Parameters:
metrics
- the metrics registry where the metrics will be storedclock
- theClock
to track time (used mostly in testing) in timerstrackFilters
- whether the processing time for request and response filters should be tracked
-
-
Method Detail
-
onEvent
public void onEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent event)
- Specified by:
onEvent
in interfaceorg.glassfish.jersey.server.monitoring.ApplicationEventListener
-
processResourceModel
public org.glassfish.jersey.server.model.ResourceModel processResourceModel(org.glassfish.jersey.server.model.ResourceModel resourceModel, javax.ws.rs.core.Configuration configuration)
- Specified by:
processResourceModel
in interfaceorg.glassfish.jersey.server.model.ModelProcessor
-
processSubResource
public org.glassfish.jersey.server.model.ResourceModel processSubResource(org.glassfish.jersey.server.model.ResourceModel subResourceModel, javax.ws.rs.core.Configuration configuration)
- Specified by:
processSubResource
in interfaceorg.glassfish.jersey.server.model.ModelProcessor
-
onRequest
public org.glassfish.jersey.server.monitoring.RequestEventListener onRequest(org.glassfish.jersey.server.monitoring.RequestEvent event)
- Specified by:
onRequest
in interfaceorg.glassfish.jersey.server.monitoring.ApplicationEventListener
-
-