This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 579464f183 ARTEMIS-5321 expose address limit percent via metrics
579464f183 is described below

commit 579464f1834d519f4565eac8985912b959f8634b
Author: Justin Bertram <[email protected]>
AuthorDate: Sat Feb 22 19:40:07 2025 -0600

    ARTEMIS-5321 expose address limit percent via metrics
---
 .../artemis/api/core/management/AddressControl.java       |  7 +++----
 .../artemis/core/management/impl/AddressControlImpl.java  |  2 +-
 .../server/management/impl/ManagementServiceImpl.java     |  1 +
 .../artemis/core/server/metrics/AddressMetricNames.java   |  1 +
 .../management/AddressControlUsingCoreTest.java           |  2 +-
 .../tests/integration/plugin/MetricsPluginTest.java       |  4 +++-
 .../tests/integration/routing/ElasticQueueTest.java       | 15 ++++++++++++---
 7 files changed, 22 insertions(+), 10 deletions(-)

diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressControl.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressControl.java
index f6ea663642..cabb21291a 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressControl.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressControl.java
@@ -27,6 +27,7 @@ public interface AddressControl {
    String UNROUTED_MESSAGE_COUNT_DESCRIPTION = "number of messages not routed 
to any bindings";
    String ADDRESS_SIZE_DESCRIPTION = "the number of estimated bytes being used 
by all the queue(s) bound to this address; used to control paging and blocking";
    String NUMBER_OF_PAGES_DESCRIPTION = "number of pages used by this address";
+   String LIMIT_PERCENT_DESCRIPTION = "the % of memory limit (global or local) 
that is in use by this address";
 
    /**
     * Returns the managed address.
@@ -124,11 +125,9 @@ public interface AddressControl {
 
    /**
     * Returns the % of memory limit that is currently in use
-    *
-    * @throws Exception
     */
-   @Attribute(desc = "the % of memory limit (global or local) that is in use 
by this address")
-   int getAddressLimitPercent() throws Exception;
+   @Attribute(desc = LIMIT_PERCENT_DESCRIPTION)
+   int getAddressLimitPercent();
 
    /**
     * Blocks message production to this address by limiting credit
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
index d8c8567d13..8a506e339d 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
@@ -417,7 +417,7 @@ public class AddressControlImpl extends AbstractControl 
implements AddressContro
    }
 
    @Override
-   public int getAddressLimitPercent() throws Exception {
+   public int getAddressLimitPercent() {
       if (AuditLogger.isBaseLoggingEnabled()) {
          AuditLogger.getAddressLimitPercent(this.addressInfo);
       }
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index d253e0e8f0..8fad753b3a 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -288,6 +288,7 @@ public class ManagementServiceImpl implements 
ManagementService {
                builder.build(AddressMetricNames.UNROUTED_MESSAGE_COUNT, 
addressInfo, metrics -> (double) addressInfo.getUnRoutedMessageCount(), 
AddressControl.UNROUTED_MESSAGE_COUNT_DESCRIPTION, Collections.emptyList());
                builder.build(AddressMetricNames.ADDRESS_SIZE, addressInfo, 
metrics -> (double) addressControl.getAddressSize(), 
AddressControl.ADDRESS_SIZE_DESCRIPTION, Collections.emptyList());
                builder.build(AddressMetricNames.PAGES_COUNT, addressInfo, 
metrics -> (double) addressControl.getNumberOfPages(), 
AddressControl.NUMBER_OF_PAGES_DESCRIPTION, Collections.emptyList());
+               builder.build(AddressMetricNames.LIMIT_PERCENT, addressInfo, 
metrics -> (double) addressControl.getAddressLimitPercent(), 
AddressControl.LIMIT_PERCENT_DESCRIPTION, Collections.emptyList());
             });
          }
       }
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/AddressMetricNames.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/AddressMetricNames.java
index c870f32fd4..9bd195bb68 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/AddressMetricNames.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/AddressMetricNames.java
@@ -22,5 +22,6 @@ public class AddressMetricNames {
    public static final String UNROUTED_MESSAGE_COUNT = 
"unrouted.message.count";
    public static final String ADDRESS_SIZE = "address.size";
    public static final String PAGES_COUNT = "number.of.pages";
+   public static final String LIMIT_PERCENT = "limit.percent";
 
 }
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java
index 612df92571..1019b97e95 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java
@@ -112,7 +112,7 @@ public class AddressControlUsingCoreTest extends 
AddressControlTest {
          }
 
          @Override
-         public int getAddressLimitPercent() throws Exception {
+         public int getAddressLimitPercent() {
             return (int)  proxy.retrieveAttributeValue("addressLimitPercent", 
Integer.class);
          }
 
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 084b54e40b..13001cf511 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
@@ -169,11 +169,13 @@ public class MetricsPluginTest extends ActiveMQTestBase {
               new Metric("artemis.unrouted.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"))),
               new Metric("artemis.address.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"))),
               new Metric("artemis.number.of.pages", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"))),
+              new Metric("artemis.limit.percent", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"))),
               // activemq.notifications metrics
               new Metric("artemis.routed.message.count", 0.0, 
Arrays.asList(Tag.of("address", "activemq.notifications"), Tag.of("broker", 
"localhost"))),
               new Metric("artemis.unrouted.message.count", 2.0, 
Arrays.asList(Tag.of("address", "activemq.notifications"), Tag.of("broker", 
"localhost"))),
               new Metric("artemis.address.size", 0.0, 
Arrays.asList(Tag.of("address", "activemq.notifications"), Tag.of("broker", 
"localhost"))),
-              new Metric("artemis.number.of.pages", 0.0, 
Arrays.asList(Tag.of("address", "activemq.notifications"), Tag.of("broker", 
"localhost")))
+              new Metric("artemis.number.of.pages", 0.0, 
Arrays.asList(Tag.of("address", "activemq.notifications"), Tag.of("broker", 
"localhost"))),
+              new Metric("artemis.limit.percent", 0.0, 
Arrays.asList(Tag.of("address", "activemq.notifications"), Tag.of("broker", 
"localhost")))
       ));
    }
 
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/routing/ElasticQueueTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/routing/ElasticQueueTest.java
index 3199c41f26..650599a56f 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/routing/ElasticQueueTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/routing/ElasticQueueTest.java
@@ -492,7 +492,10 @@ public class ElasticQueueTest extends ActiveMQTestBase {
             int usage = addressControl1.getAddressLimitPercent();
             System.out.println("Node1 (head) usage % " + usage);
             return usage > 10;
-         } catch (javax.management.InstanceNotFoundException 
notYetReadyExpected) {
+         } catch (Exception e) {
+            if (!(e.getCause() instanceof 
javax.management.InstanceNotFoundException)) {
+               throw e;
+            }
          }
          return false;
       }, 5000, 200), "Producer is on Head, Node1");
@@ -560,7 +563,10 @@ public class ElasticQueueTest extends ActiveMQTestBase {
             int usage = addressControl0.getAddressLimitPercent();
             System.out.println("Head&Tail usage % " + usage);
             return usage == 100;
-         } catch (javax.management.InstanceNotFoundException 
notYetReadyExpected) {
+         } catch (Exception e) {
+            if (!(e.getCause() instanceof 
javax.management.InstanceNotFoundException)) {
+               throw e;
+            }
          }
          return false;
       }, 10000, 200));
@@ -659,7 +665,10 @@ public class ElasticQueueTest extends ActiveMQTestBase {
             int usage = addressControl0.getAddressLimitPercent();
             System.out.println("Head&Tail usage % " + usage);
             return usage == 100;
-         } catch (javax.management.InstanceNotFoundException 
notYetReadyExpected) {
+         } catch (Exception e) {
+            if (!(e.getCause() instanceof 
javax.management.InstanceNotFoundException)) {
+               throw e;
+            }
          }
          return false;
       }, 20000, 200));


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to