clebertsuconic commented on code in PR #5999:
URL: https://github.com/apache/activemq-artemis/pull/5999#discussion_r2452837754


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java:
##########
@@ -126,65 +139,25 @@ public int hashCode() {
          }
       }
 
-      final String queueName = "simpleQueue";
-      final String addressName = "simpleAddress";
-      
session.createQueue(QueueConfiguration.of(queueName).setAddress(addressName).setRoutingType(RoutingType.ANYCAST));
 
-      Map<Meter.Id, Double> metrics = getMetrics();
-      List<Metric> artemisMetrics = metrics.entrySet().stream()
-              .map(entry -> new Metric(
-                      entry.getKey().getName(),
-                      entry.getValue(),
-                      entry.getKey().getTags()))
-              .filter(metric -> metric.name.startsWith("artemis"))
-              .collect(Collectors.toList());
-
-      assertThat(artemisMetrics, containsInAnyOrder(
-              // broker metrics
-              new Metric("artemis.address.memory.usage",  0.0, 
Arrays.asList(Tag.of("broker", "localhost"))),
-              new Metric("artemis.address.memory.usage.percentage", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"))),
-              new Metric("artemis.connection.count", 1.0, 
Arrays.asList(Tag.of("broker", "localhost"))),
-              new Metric("artemis.total.connection.count", 1.0, 
Arrays.asList(Tag.of("broker", "localhost"))),
-              new Metric("artemis.session.count", 1.0, 
Arrays.asList(Tag.of("broker", "localhost"))),
-              new Metric("artemis.total.session.count", 1.0, 
Arrays.asList(Tag.of("broker", "localhost"))),
-              new Metric("artemis.active", 1.0, Arrays.asList(Tag.of("broker", 
"localhost"))),
-              new Metric("artemis.replica.sync", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"))),
-              new Metric("artemis.disk.store.usage", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"))),
-              new Metric("artemis.authentication.count", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"), Tag.of("result", "success"))),
-              new Metric("artemis.authentication.count", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"), Tag.of("result", "failure"))),
-              new Metric("artemis.authorization.count", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"), Tag.of("result", "success"))),
-              new Metric("artemis.authorization.count", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"), Tag.of("result", "failure"))),
-              // simpleQueue metrics
-              new Metric("artemis.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.durable.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.durable.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.delivering.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.delivering.durable.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.delivering.persistent_size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.delivering.durable.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.scheduled.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.scheduled.durable.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.scheduled.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.scheduled.durable.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.messages.acknowledged", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.messages.added", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.messages.killed", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.messages.expired", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              new Metric("artemis.consumer.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
-              // simpleAddress metrics
-              new Metric("artemis.routed.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"))),
-              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.limit.percent", 0.0, 
Arrays.asList(Tag.of("address", "activemq.notifications"), Tag.of("broker", 
"localhost")))
-      ));
+      try {
+         Map<Meter.Id, Double> metrics = getMetrics();
+         List<Metric> artemisMetrics = metrics.entrySet().stream().map(entry 
-> new Metric(entry.getKey().getName(), entry.getValue(), 
entry.getKey().getTags())).filter(metric -> 
metric.name.startsWith("artemis")).collect(Collectors.toList());
+
+         assertThat(artemisMetrics, containsInAnyOrder(
+            // broker metrics
+            new Metric("artemis.address.memory.usage", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"))), new 
Metric("artemis.address.memory.usage.percentage", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"))), new 
Metric("artemis.connection.count", 1.0, Arrays.asList(Tag.of("broker", 
"localhost"))), new Metric("artemis.total.connection.count", 1.0, 
Arrays.asList(Tag.of("broker", "localhost"))), new 
Metric("artemis.session.count", 1.0, Arrays.asList(Tag.of("broker", 
"localhost"))), new Metric("artemis.total.session.count", 1.0, 
Arrays.asList(Tag.of("broker", "localhost"))), new Metric("artemis.active", 
1.0, Arrays.asList(Tag.of("broker", "localhost"))), new 
Metric("artemis.replica.sync", 0.0, Arrays.asList(Tag.of("broker", 
"localhost"))), new Metric("artemis.disk.store.usage", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"))), new 
Metric("artemis.authentication.count", 0.0, Arrays.asList(Tag.of("broker", 
"localhost"), Tag.of("result", "success"))), new Metric("artemis.authenticat
 ion.count", 0.0, Arrays.asList(Tag.of("broker", "localhost"), Tag.of("result", 
"failure"))), new Metric("artemis.authorization.count", 0.0, 
Arrays.asList(Tag.of("broker", "localhost"), Tag.of("result", "success"))), new 
Metric("artemis.authorization.count", 0.0, Arrays.asList(Tag.of("broker", 
"localhost"), Tag.of("result", "failure"))),
+            // simpleQueue metrics
+            new Metric("artemis.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.durable.message.count", 0.0, Arrays.asList(Tag.of("address", 
"simpleAddress"), Tag.of("broker", "localhost"), Tag.of("queue", 
"simpleQueue"))), new Metric("artemis.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.durable.persistent.size", 0.0, Arrays.asList(Tag.of("address", 
"simpleAddress"), Tag.of("broker", "localhost"), Tag.of("queue", 
"simpleQueue"))), new Metric("artemis.delivering.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.delivering.durable.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
  new Metric("artemis.delivering.persistent_size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.delivering.durable.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.scheduled.message.count", 0.0, Arrays.asList(Tag.of("address", 
"simpleAddress"), Tag.of("broker", "localhost"), Tag.of("queue", 
"simpleQueue"))), new Metric("artemis.scheduled.durable.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.scheduled.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.scheduled.durable.persistent.size", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), 
 Tag.of("queue", "simpleQueue"))), new Metric("artemis.messages.acknowledged", 
0.0, Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.messages.added", 0.0, Arrays.asList(Tag.of("address", 
"simpleAddress"), Tag.of("broker", "localhost"), Tag.of("queue", 
"simpleQueue"))), new Metric("artemis.messages.killed", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))), new 
Metric("artemis.messages.expired", 0.0, Arrays.asList(Tag.of("address", 
"simpleAddress"), Tag.of("broker", "localhost"), Tag.of("queue", 
"simpleQueue"))), new Metric("artemis.consumer.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"), Tag.of("queue", "simpleQueue"))),
+            // simpleAddress metrics
+            new Metric("artemis.routed.message.count", 0.0, 
Arrays.asList(Tag.of("address", "simpleAddress"), Tag.of("broker", 
"localhost"))), 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.limit.percent", 0.0, 
Arrays.asList(Tag.of("address", "activemq.notifications"), Tag.of("broker", 
"localhost")))));

Review Comment:
   @gemmellr i will keep the previous format. I was having a hard time with 
Idea..
   
   the reason I didn't do it was because I wasn't sure if Justin would find a 
better way to do a proper comparison with Hamcrest instead of throwing an error 
like I'm doing. 
   
   I tried using the API and It was failing for me.. I went for the fast 
approach now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
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