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
ConstructorsConstructorDescriptionInstrumentedResourceMethodApplicationListener(com.codahale.metrics.MetricRegistry metrics) Construct an application event listener using the given metrics registry.InstrumentedResourceMethodApplicationListener(com.codahale.metrics.MetricRegistry metrics, com.codahale.metrics.Clock clock, boolean trackFilters) Constructs a custom application listener.InstrumentedResourceMethodApplicationListener(com.codahale.metrics.MetricRegistry metrics, com.codahale.metrics.Clock clock, boolean trackFilters, Supplier<com.codahale.metrics.Reservoir> reservoirSupplier) Constructs a custom application listener. -
Method Summary
Modifier and TypeMethodDescriptionprotected static StringchooseName(String explicitName, boolean absolute, org.glassfish.jersey.server.model.ResourceMethod method, String... suffixes) voidonEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent event) org.glassfish.jersey.server.monitoring.RequestEventListeneronRequest(org.glassfish.jersey.server.monitoring.RequestEvent event) org.glassfish.jersey.server.model.ResourceModelprocessResourceModel(org.glassfish.jersey.server.model.ResourceModel resourceModel, javax.ws.rs.core.Configuration configuration) org.glassfish.jersey.server.model.ResourceModelprocessSubResource(org.glassfish.jersey.server.model.ResourceModel subResourceModel, javax.ws.rs.core.Configuration configuration)
-
Constructor Details
-
InstrumentedResourceMethodApplicationListener
public InstrumentedResourceMethodApplicationListener(com.codahale.metrics.MetricRegistry metrics) Construct an application event listener using the given metrics registry.When using this constructor, the
InstrumentedResourceMethodApplicationListenershould be added to a JerseyResourceConfigas a singleton.- Parameters:
metrics- aMetricRegistry
-
InstrumentedResourceMethodApplicationListener
public InstrumentedResourceMethodApplicationListener(com.codahale.metrics.MetricRegistry metrics, com.codahale.metrics.Clock clock, boolean trackFilters) Constructs a custom application listener.- Parameters:
metrics- the metrics registry where the metrics will be storedclock- theClockto track time (used mostly in testing) in timerstrackFilters- whether the processing time for request and response filters should be tracked
-
InstrumentedResourceMethodApplicationListener
public InstrumentedResourceMethodApplicationListener(com.codahale.metrics.MetricRegistry metrics, com.codahale.metrics.Clock clock, boolean trackFilters, Supplier<com.codahale.metrics.Reservoir> reservoirSupplier) Constructs a custom application listener.- Parameters:
metrics- the metrics registry where the metrics will be storedclock- theClockto track time (used mostly in testing) in timerstrackFilters- whether the processing time for request and response filters should be trackedreservoirSupplier- Supplier for creating theReservoirfortimers.
-
-
Method Details
-
onEvent
public void onEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent event) - Specified by:
onEventin 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:
processResourceModelin 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:
processSubResourcein interfaceorg.glassfish.jersey.server.model.ModelProcessor
-
onRequest
public org.glassfish.jersey.server.monitoring.RequestEventListener onRequest(org.glassfish.jersey.server.monitoring.RequestEvent event) - Specified by:
onRequestin interfaceorg.glassfish.jersey.server.monitoring.ApplicationEventListener
-
chooseName
-