Class MonitoringHandler
- java.lang.Object
-
- org.swisspush.gateleen.monitoring.MonitoringHandler
-
public class MonitoringHandler extends java.lang.ObjectHandler 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]
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMonitoringHandler.MonitoringCallback
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACTIVE_QUEUE_COUNT_METRICstatic java.lang.StringDEQUEUE_METRICstatic java.lang.StringENQUEUE_METRICstatic java.lang.StringLAST_USED_QUEUE_SIZE_METRICstatic java.lang.StringLISTENER_COUNT_METRICstatic java.lang.StringMARKstatic intMAX_AGE_MILLISECONDSDeprecated.static java.lang.StringMETRIC_ACTIONstatic java.lang.StringMETRIC_NAMEstatic java.lang.StringPENDING_REQUESTS_METRICstatic java.lang.StringQUEUES_KEY_PREFIXDeprecated.static longREQUEST_PER_RULE_DEFAULT_EXPIRYstatic longREQUEST_PER_RULE_DEFAULT_SAMPLINGstatic java.lang.StringREQUEST_PER_RULE_EXPIRY_PROPERTYstatic java.lang.StringREQUEST_PER_RULE_PREFIXstatic java.lang.StringREQUEST_PER_RULE_PROPERTYstatic java.lang.StringREQUEST_PER_RULE_SAMPLING_PROPERTYstatic java.lang.StringREQUESTS_BACKENDS_NAMEstatic java.lang.StringREQUESTS_CLIENT_NAMEstatic java.lang.StringROUTE_COUNT_METRICstatic java.lang.StringSET
-
Constructor Summary
Constructors Constructor Description MonitoringHandler(io.vertx.core.Vertx vertx, io.vertx.redis.RedisClient redisClient, org.swisspush.gateleen.core.storage.ResourceStorage storage, java.lang.String prefix)Deprecated.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)Deprecated.MonitoringHandler(io.vertx.core.Vertx vertx, org.swisspush.gateleen.core.storage.ResourceStorage storage, java.lang.String prefix)MonitoringHandler(io.vertx.core.Vertx vertx, org.swisspush.gateleen.core.storage.ResourceStorage storage, java.lang.String prefix, java.lang.String requestPerRulePath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringgetMonitoringAddress()Get the event bus address of the monitoring.protected java.lang.StringgetRedisquesAddress()Get the event bus address of redisques.longgetRequestPerRuleExpiry()java.lang.StringgetRequestPerRuleMonitoringPath()longgetRequestPerRuleSampling()booleanisRequestPerRuleMonitoringActive()longstartRequestMetricTracking(java.lang.String metricName, java.lang.String targetUri)Start the metric tracking for the requests defined with the metricName (routing rule)voidstopRequestMetricTracking(java.lang.String metricName, long startTime, java.lang.String targetUri)Stop the metric tracking for the requests defined with the metricName (routing rule)voidupdateDequeue()voidupdateEnqueue()voidupdateIncomingRequests(io.vertx.core.http.HttpServerRequest request)voidupdateLastUsedQueueSizeInformation(java.lang.String queue)Reads the size from the last used Queue from redis and stores it to JMXvoidupdateListenerCount(long count)voidupdateQueueCountInformation()Update the count of active queues.voidupdateQueuesSizesInformation(int numQueues, boolean showEmptyQueues, MonitoringHandler.MonitoringCallback callback)Updates the information about the sizes of the top (numQueues) sized queues.voidupdateRequestPerRuleMonitoring(io.vertx.core.http.HttpServerRequest request, java.lang.String metricName)voidupdateRequestsMeter(java.lang.String target, java.lang.String uri)Update the meter values for requests.voidupdateRoutesCount(long count)
-
-
-
Field Detail
-
METRIC_NAME
public static final java.lang.String METRIC_NAME
- See Also:
- Constant Field Values
-
METRIC_ACTION
public static final java.lang.String METRIC_ACTION
- See Also:
- Constant Field Values
-
MARK
public static final java.lang.String MARK
- See Also:
- Constant Field Values
-
SET
public static final java.lang.String SET
- See Also:
- Constant Field Values
-
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
-
ENQUEUE_METRIC
public static final java.lang.String ENQUEUE_METRIC
- See Also:
- Constant Field Values
-
DEQUEUE_METRIC
public static final java.lang.String DEQUEUE_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)Deprecated.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)Deprecated.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 requesturi- 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 timetargetUri- 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 queuesshowEmptyQueues- show empty queues or notcallback- 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)
-
-