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(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 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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 InstrumentedResourceMethodApplicationListener should be added to a Jersey ResourceConfig as a singleton.

      Parameters:
      metrics - a MetricRegistry
    • 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 stored
      clock - the Clock to track time (used mostly in testing) in timers
      trackFilters - 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 stored
      clock - the Clock to track time (used mostly in testing) in timers
      trackFilters - whether the processing time for request and response filters should be tracked
      reservoirSupplier - Supplier for creating the Reservoir for timers.
  • Method Details

    • onEvent

      public void onEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent event)
      Specified by:
      onEvent in interface org.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 interface org.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 interface org.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 interface org.glassfish.jersey.server.monitoring.ApplicationEventListener
    • chooseName

      protected static String chooseName(String explicitName, boolean absolute, org.glassfish.jersey.server.model.ResourceMethod method, String... suffixes)