Class 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 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 Jersey ResourceConfig as a singleton.

        Parameters:
        metrics - a MetricRegistry
      • InstrumentedResourceMethodApplicationListener

        public InstrumentedResourceMethodApplicationListener​(MetricRegistry 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
    • Method Detail

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