Class MonitoringHandler


  • public class MonitoringHandler
    extends java.lang.Object
    Handler to monitor the server state using the Metrics library. The recorded informations are accessible through JMX MBeans.
    Author:
    https://github.com/mcweba [Marc-Andre Weber]
    • Field Detail

      • REQUESTS_CLIENT_NAME

        public static final java.lang.String REQUESTS_CLIENT_NAME
        See Also:
        Constant Field Values
      • REQUESTS_BACKENDS_NAME

        public static final java.lang.String REQUESTS_BACKENDS_NAME
        See Also:
        Constant Field Values
      • PENDING_REQUESTS_METRIC

        public static final java.lang.String PENDING_REQUESTS_METRIC
        See Also:
        Constant Field Values
      • ACTIVE_QUEUE_COUNT_METRIC

        public static final java.lang.String ACTIVE_QUEUE_COUNT_METRIC
        See Also:
        Constant Field Values
      • LAST_USED_QUEUE_SIZE_METRIC

        public static final java.lang.String LAST_USED_QUEUE_SIZE_METRIC
        See Also:
        Constant Field Values
      • LISTENER_COUNT_METRIC

        public static final java.lang.String LISTENER_COUNT_METRIC
        See Also:
        Constant Field Values
      • ROUTE_COUNT_METRIC

        public static final java.lang.String ROUTE_COUNT_METRIC
        See Also:
        Constant Field Values
      • QUEUES_KEY_PREFIX

        @Deprecated
        public static final java.lang.String QUEUES_KEY_PREFIX
        Deprecated.
        See Also:
        Constant Field Values
      • MAX_AGE_MILLISECONDS

        @Deprecated
        public static final int MAX_AGE_MILLISECONDS
        Deprecated.
        See Also:
        Constant Field Values
      • REQUEST_PER_RULE_PREFIX

        public static final java.lang.String REQUEST_PER_RULE_PREFIX
        See Also:
        Constant Field Values
      • REQUEST_PER_RULE_PROPERTY

        public static final java.lang.String REQUEST_PER_RULE_PROPERTY
        See Also:
        Constant Field Values
      • REQUEST_PER_RULE_SAMPLING_PROPERTY

        public static final java.lang.String REQUEST_PER_RULE_SAMPLING_PROPERTY
        See Also:
        Constant Field Values
      • REQUEST_PER_RULE_EXPIRY_PROPERTY

        public static final java.lang.String REQUEST_PER_RULE_EXPIRY_PROPERTY
        See Also:
        Constant Field Values
      • REQUEST_PER_RULE_DEFAULT_SAMPLING

        public static final long REQUEST_PER_RULE_DEFAULT_SAMPLING
        See Also:
        Constant Field Values
      • REQUEST_PER_RULE_DEFAULT_EXPIRY

        public static final long REQUEST_PER_RULE_DEFAULT_EXPIRY
        See Also:
        Constant Field Values
    • Constructor Detail

      • MonitoringHandler

        @Deprecated
        public MonitoringHandler​(io.vertx.core.Vertx vertx,
                                 io.vertx.redis.RedisClient redisClient,
                                 org.swisspush.gateleen.core.storage.ResourceStorage storage,
                                 java.lang.String prefix)
        Constructor
      • MonitoringHandler

        @Deprecated
        public MonitoringHandler​(io.vertx.core.Vertx vertx,
                                 io.vertx.redis.RedisClient redisClient,
                                 org.swisspush.gateleen.core.storage.ResourceStorage storage,
                                 java.lang.String prefix,
                                 java.lang.String requestPerRulePath)
        Constructor
      • MonitoringHandler

        public MonitoringHandler​(io.vertx.core.Vertx vertx,
                                 org.swisspush.gateleen.core.storage.ResourceStorage storage,
                                 java.lang.String prefix)
      • MonitoringHandler

        public MonitoringHandler​(io.vertx.core.Vertx vertx,
                                 org.swisspush.gateleen.core.storage.ResourceStorage storage,
                                 java.lang.String prefix,
                                 java.lang.String requestPerRulePath)
    • Method Detail

      • getMonitoringAddress

        protected java.lang.String getMonitoringAddress()
        Get the event bus address of the monitoring. Override this method when you want to use a custom monitoring address
        Returns:
        the event bus address of monitoring
      • getRedisquesAddress

        protected java.lang.String getRedisquesAddress()
        Get the event bus address of redisques. Override this method when you want to use a custom redisques address
        Returns:
        the event bus address of redisques
      • getRequestPerRuleMonitoringPath

        public java.lang.String getRequestPerRuleMonitoringPath()
      • isRequestPerRuleMonitoringActive

        public boolean isRequestPerRuleMonitoringActive()
      • getRequestPerRuleSampling

        public long getRequestPerRuleSampling()
      • getRequestPerRuleExpiry

        public long getRequestPerRuleExpiry()
      • updateIncomingRequests

        public void updateIncomingRequests​(io.vertx.core.http.HttpServerRequest request)
      • updateRequestPerRuleMonitoring

        public void updateRequestPerRuleMonitoring​(io.vertx.core.http.HttpServerRequest request,
                                                   java.lang.String metricName)
      • updateRequestsMeter

        public void updateRequestsMeter​(java.lang.String target,
                                        java.lang.String uri)
        Update the meter values for requests. Requests from clients and requests to other backends are measured separately.
        Parameters:
        target - the target url of the request
        uri - uri
      • startRequestMetricTracking

        public long startRequestMetricTracking​(java.lang.String metricName,
                                               java.lang.String targetUri)
        Start the metric tracking for the requests defined with the metricName (routing rule)
        Parameters:
        metricName - the name of the metric. This name will be used as name of the JMX MBean. metricNames are defined in routing rules with the property "metricName"
        targetUri - targetUri
        Returns:
        long
      • stopRequestMetricTracking

        public void stopRequestMetricTracking​(java.lang.String metricName,
                                              long startTime,
                                              java.lang.String targetUri)
        Stop the metric tracking for the requests defined with the metricName (routing rule)
        Parameters:
        metricName - the name of the metric. This name will be used as name of the JMX MBean. metricNames are defined in routing rules with the property "metricName"
        startTime - start time
        targetUri - target uri
      • updateQueueCountInformation

        public void updateQueueCountInformation()
        Update the count of active queues. Reads the count from redis and stores it to JMX.
      • updateLastUsedQueueSizeInformation

        public void updateLastUsedQueueSizeInformation​(java.lang.String queue)
        Reads the size from the last used Queue from redis and stores it to JMX
        Parameters:
        queue - the name of the queue the last update was made
      • updateQueuesSizesInformation

        public void updateQueuesSizesInformation​(int numQueues,
                                                 boolean showEmptyQueues,
                                                 MonitoringHandler.MonitoringCallback callback)
        Updates the information about the sizes of the top (numQueues) sized queues.
        Parameters:
        numQueues - the number of queues
        showEmptyQueues - show empty queues or not
        callback - the callback returning the result
      • updateEnqueue

        public void updateEnqueue()
      • updateDequeue

        public void updateDequeue()
      • updateListenerCount

        public void updateListenerCount​(long count)
      • updateRoutesCount

        public void updateRoutesCount​(long count)