ARTEMIS-2827 add addressMemoryUsagePercentage as metric

This commit is contained in:
Justin Bertram 2020-06-26 13:35:04 -05:00 committed by Clebert Suconic
parent 26091f1907
commit ac8ffedf66
4 changed files with 10 additions and 5 deletions

View File

@ -27,7 +27,8 @@ import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException
public interface ActiveMQServerControl {
String CONNECTION_COUNT_DESCRIPTION = "Number of clients connected to this server";
String TOTAL_CONNECTION_COUNT_DESCRIPTION = "Number of clients which have connected to this server since it was started";
String ADDRESS_MEMORY_USAGE_DESCRIPTION = "Bytes used by all the addresses on broker for in-memory messages";
String ADDRESS_MEMORY_USAGE_DESCRIPTION = "Memory used by all the addresses on broker for in-memory messages";
String ADDRESS_MEMORY_USAGE_PERCENTAGE_DESCRIPTION = "Memory used by all the addresses on broker as a percentage of the global-max-size";
String DISK_STORE_USAGE_DESCRIPTION = "Memory used by the disk store";
/**
@ -450,9 +451,9 @@ public interface ActiveMQServerControl {
long getDiskStoreUsage();
/**
* Returns the memory used by all the addresses on broker as a percentage of global maximum limit
* Returns the memory used by all the addresses on broker as a percentage of the global-max-size
*/
@Attribute(desc = "Memory used by all the addresses on broker as a percentage of global maximum limit")
@Attribute(desc = ADDRESS_MEMORY_USAGE_PERCENTAGE_DESCRIPTION)
int getAddressMemoryUsagePercentage();
// Operations ----------------------------------------------------

View File

@ -3084,7 +3084,8 @@ public class ActiveMQServerImpl implements ActiveMQServer {
metricsManager.registerBrokerGauge(builder -> {
builder.register(BrokerMetricNames.CONNECTION_COUNT, this, metrics -> Double.valueOf(getConnectionCount()), ActiveMQServerControl.CONNECTION_COUNT_DESCRIPTION);
builder.register(BrokerMetricNames.TOTAL_CONNECTION_COUNT, this, metrics -> Double.valueOf(getTotalConnectionCount()), ActiveMQServerControl.TOTAL_CONNECTION_COUNT_DESCRIPTION);
builder.register(BrokerMetricNames.ADDRESS_MEMORY_USAGE, this, metrics -> Double.valueOf(getPagingManager().getGlobalSize()), ActiveMQServerControl.ADDRESS_MEMORY_USAGE_DESCRIPTION);
builder.register(BrokerMetricNames.ADDRESS_MEMORY_USAGE, this, metrics -> Double.valueOf(messagingServerControl.getAddressMemoryUsage()), ActiveMQServerControl.ADDRESS_MEMORY_USAGE_DESCRIPTION);
builder.register(BrokerMetricNames.ADDRESS_MEMORY_USAGE_PERCENTAGE, this, metrics -> Double.valueOf(messagingServerControl.getAddressMemoryUsagePercentage()), ActiveMQServerControl.ADDRESS_MEMORY_USAGE_PERCENTAGE_DESCRIPTION);
builder.register(BrokerMetricNames.DISK_STORE_USAGE, this, metrics -> Double.valueOf(calculateDiskStoreUsage()), ActiveMQServerControl.DISK_STORE_USAGE_DESCRIPTION);
});
}

View File

@ -22,5 +22,6 @@ public class BrokerMetricNames {
public static final String CONNECTION_COUNT = "connection.count";
public static final String TOTAL_CONNECTION_COUNT = "total.connection.count";
public static final String ADDRESS_MEMORY_USAGE = "address.memory.usage";
public static final String ADDRESS_MEMORY_USAGE_PERCENTAGE = "address.memory.usage.percentage";
public static final String DISK_STORE_USAGE = "disk.store.usage";
}

View File

@ -40,6 +40,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.config.MetricsConfiguration;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.metrics.plugins.SimpleMetricsPlugin;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
@ -140,7 +141,8 @@ public class MetricsPluginTest extends ActiveMQTestBase {
assertThat(artemisMetrics, containsInAnyOrder(
// artemis.(un)routed.message.count is present twice, because of activemq.notifications address
new Metric("artemis.address.memory.usage", "Bytes used by all the addresses on broker for in-memory messages", 0.0),
new Metric("artemis.address.memory.usage", "Memory used by all the addresses on broker for in-memory messages", 0.0),
new Metric("artemis.address.memory.usage.percentage", "Memory used by all the addresses on broker as a percentage of the global-max-size", 0.0),
new Metric("artemis.connection.count", "Number of clients connected to this server", 1.0),
new Metric("artemis.consumer.count", "number of consumers consuming messages from this queue", 0.0),
new Metric("artemis.delivering.durable.message.count", "number of durable messages that this queue is currently delivering to its consumers", 0.0),