diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java index b8df6d7d72..c7958350dd 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java @@ -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 ---------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 722e74f21d..6d78f16d5b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -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); }); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/BrokerMetricNames.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/BrokerMetricNames.java index 47ef5cff48..a3c4904a2e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/BrokerMetricNames.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/BrokerMetricNames.java @@ -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"; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java index e661754031..600145158d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java @@ -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),