Class MonitoringHandler
- java.lang.Object
-
- org.swisspush.gateleen.monitoring.MonitoringHandler
-
public class MonitoringHandler extends 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]
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMonitoringHandler.MonitoringCallback
-
Field Summary
Fields Modifier and Type Field Description static StringACTIVE_QUEUE_COUNT_METRICstatic StringDEQUEUE_METRICstatic StringENQUEUE_METRICstatic StringLAST_USED_QUEUE_SIZE_METRICstatic StringLISTENER_COUNT_METRICstatic StringMARKstatic intMAX_AGE_MILLISECONDSDeprecated.static StringMETRIC_ACTIONstatic StringMETRIC_NAMEstatic StringPENDING_REQUESTS_METRICstatic StringQUEUES_KEY_PREFIXDeprecated.static longREQUEST_PER_RULE_DEFAULT_EXPIRYstatic longREQUEST_PER_RULE_DEFAULT_SAMPLINGstatic StringREQUEST_PER_RULE_EXPIRY_PROPERTYstatic StringREQUEST_PER_RULE_PREFIXstatic StringREQUEST_PER_RULE_PROPERTYstatic StringREQUEST_PER_RULE_SAMPLING_PROPERTYstatic StringREQUESTS_BACKENDS_NAMEstatic StringREQUESTS_CLIENT_NAMEstatic StringROUTE_COUNT_METRICstatic StringSET
-
Constructor Summary
Constructors Constructor Description MonitoringHandler(io.vertx.core.Vertx vertx, io.vertx.redis.client.impl.RedisClient redisClient, ResourceStorage storage, String prefix)Deprecated.MonitoringHandler(io.vertx.core.Vertx vertx, io.vertx.redis.client.impl.RedisClient redisClient, ResourceStorage storage, String prefix, String requestPerRulePath)Deprecated.MonitoringHandler(io.vertx.core.Vertx vertx, ResourceStorage storage, String prefix)MonitoringHandler(io.vertx.core.Vertx vertx, ResourceStorage storage, String prefix, String requestPerRulePath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetMonitoringAddress()Get the event bus address of the monitoring.protected StringgetRedisquesAddress()Get the event bus address of redisques.longgetRequestPerRuleExpiry()StringgetRequestPerRuleMonitoringPath()longgetRequestPerRuleSampling()booleanisRequestPerRuleMonitoringActive()voidregisterReceiver(io.vertx.core.Handler<io.vertx.core.eventbus.Message<io.vertx.core.json.JsonObject>> receiver)Register an external receiver interested in monitoring data.longstartRequestMetricTracking(String metricName, String targetUri)Start the metric tracking for the requests defined with the metricName (routing rule)voidstopRequestMetricTracking(String metricName, long startTime, 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(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, String metricName)voidupdateRequestsMeter(String target, String uri)Update the meter values for requests.voidupdateRoutesCount(long count)
-
-
-
Field Detail
-
METRIC_NAME
public static final String METRIC_NAME
- See Also:
- Constant Field Values
-
METRIC_ACTION
public static final String METRIC_ACTION
- See Also:
- Constant Field Values
-
MARK
public static final String MARK
- See Also:
- Constant Field Values
-
SET
public static final String SET
- See Also:
- Constant Field Values
-
REQUESTS_CLIENT_NAME
public static final String REQUESTS_CLIENT_NAME
- See Also:
- Constant Field Values
-
REQUESTS_BACKENDS_NAME
public static final String REQUESTS_BACKENDS_NAME
- See Also:
- Constant Field Values
-
PENDING_REQUESTS_METRIC
public static final String PENDING_REQUESTS_METRIC
- See Also:
- Constant Field Values
-
ACTIVE_QUEUE_COUNT_METRIC
public static final String ACTIVE_QUEUE_COUNT_METRIC
- See Also:
- Constant Field Values
-
LAST_USED_QUEUE_SIZE_METRIC
public static final String LAST_USED_QUEUE_SIZE_METRIC
- See Also:
- Constant Field Values
-
ENQUEUE_METRIC
public static final String ENQUEUE_METRIC
- See Also:
- Constant Field Values
-
DEQUEUE_METRIC
public static final String DEQUEUE_METRIC
- See Also:
- Constant Field Values
-
LISTENER_COUNT_METRIC
public static final String LISTENER_COUNT_METRIC
- See Also:
- Constant Field Values
-
ROUTE_COUNT_METRIC
public static final String ROUTE_COUNT_METRIC
- See Also:
- Constant Field Values
-
QUEUES_KEY_PREFIX
@Deprecated public static final 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 String REQUEST_PER_RULE_PREFIX
- See Also:
- Constant Field Values
-
REQUEST_PER_RULE_PROPERTY
public static final String REQUEST_PER_RULE_PROPERTY
- See Also:
- Constant Field Values
-
REQUEST_PER_RULE_SAMPLING_PROPERTY
public static final String REQUEST_PER_RULE_SAMPLING_PROPERTY
- See Also:
- Constant Field Values
-
REQUEST_PER_RULE_EXPIRY_PROPERTY
public static final 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.client.impl.RedisClient redisClient, ResourceStorage storage, String prefix)
Deprecated.Constructor
-
MonitoringHandler
@Deprecated public MonitoringHandler(io.vertx.core.Vertx vertx, io.vertx.redis.client.impl.RedisClient redisClient, ResourceStorage storage, String prefix, String requestPerRulePath)
Deprecated.Constructor
-
MonitoringHandler
public MonitoringHandler(io.vertx.core.Vertx vertx, ResourceStorage storage, String prefix)
-
MonitoringHandler
public MonitoringHandler(io.vertx.core.Vertx vertx, ResourceStorage storage, String prefix, String requestPerRulePath)
-
-
Method Detail
-
registerReceiver
public void registerReceiver(io.vertx.core.Handler<io.vertx.core.eventbus.Message<io.vertx.core.json.JsonObject>> receiver)
Register an external receiver interested in monitoring data.- Parameters:
receiver- a handler
-
getMonitoringAddress
protected 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 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 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, String metricName)
-
updateRequestsMeter
public void updateRequestsMeter(String target, 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(String metricName, 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(String metricName, long startTime, 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(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)
-
-