Skip to content

Commit

Permalink
Added activeMQ update
Browse files Browse the repository at this point in the history
  • Loading branch information
armstrmi committed Jan 13, 2022
1 parent 8a97c48 commit e000aa8
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 131 deletions.
61 changes: 43 additions & 18 deletions jmx-metrics/docs/target-systems/activemq.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,61 @@ These metrics are sourced from: https://activemq.apache.org/jmx
* Instrument Type: LongUpDownCounterCallback


* Name: `activemq.connection.count`
* Description: The total number of current connections.
* Unit: `{connections}`
* Instrument Type: LongUpDownCounterCallback


* Name: `activemq.memory.usage`
* Description: The percentage of configured memory used.
* Unit: `%`
* Labels: `destination`
* Instrument Type: DoubleValueCallback


* Name: `tomcat.traffic`
* Description: The number of bytes transmitted and received.
* Unit: `by`
* Labels: `proto_handler`, `direction`
* Instrument Type: LongCounterCallback
* Name: `activemq.disk.store_usage`
* Description: The percentage of configured disk used for persistent messages.
* Unit: `%`
* Instrument Type: DoubleValueCallback


* Name: `tomcat.threads`
* Description: The number of threads.
* Unit: `threads`
* Labels: `proto_handler`, `state`
* Instrument Type: LongValueCallback
* Name: `activemq.disk.temp_usage`
* Description: The percentage of configured disk used for non-persistent messages.
* Unit: `%`
* Instrument Type: DoubleValueCallback


* Name: `tomcat.max_time`
* Description: Maximum time to process a request.
* Unit: `ms`
* Labels: `proto_handler`
* Name: `activemq.message.current`
* Description: The current number of messages waiting to be consumed.
* Unit: `messages`
* Labels: `destination`
* Instrument Type: LongUpDownCounterCallback


* Name: `activemq.message.expired`
* Description: The total number of messages not delivered because they expired.
* Unit: `messages`
* Labels: `destination`
* Instrument Type: LongCounterCallback


* Name: `activemq.message.enqueued`
* Description: The total number of messages received by the broker.
* Unit: `messages`
* Labels: `destination`
* Instrument Type: LongCounterCallback


* Name: `tomcat.request_count`
* Description: The total requests.
* Unit: `requests`
* Labels: `proto_handler`
* Name: `activemq.message.dequeued`
* Description: The total number of messages delivered to consumers.
* Unit: `messages`
* Labels: `destination`
* Instrument Type: LongCounterCallback


* Name: `activemq.wait_time.avg`
* Description: The average time a message was held on a destination.
* Unit: `ms`
* Labels: `destination`
* Instrument Type: DoubleValueCallback
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void beforeEach() {
@SafeVarargs
protected final void waitAndAssertMetrics(Consumer<Metric>... assertions) {
await()
.atMost(Duration.ofMinutes(2))
.atMost(Duration.ofSeconds(30))
.untilAsserted(
() -> {
List<Metric> metrics =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.utility.MountableFile;

class ActivemqIntegrationTest extends AbstractIntegrationTest {

Expand All @@ -27,24 +26,8 @@ class ActivemqIntegrationTest extends AbstractIntegrationTest {
GenericContainer<?> activemq =
new GenericContainer<>(
new ImageFromDockerfile()
.withDockerfileFromBuilder(
builder ->
builder
.from("rmohr/activemq:5.15.9-alpine")
.expose(10991)
.env(
"ACTIVEMQ_JMX_OPTS",
"-Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.port=10991 -Dcom.sun.management.jmxremote.rmi.port=10991 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false")
.env("ACTIVEMQ_JMX", "10991")
// .env("ACTIVEMQ_OPTS","$ACTIVEMQ_JMX_OPTS
// -Dhawtio.authenticationEnabled=false -Dhawtio.realm=activemq
// -Dhawtio.role=admins
// -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal")
//
// .env("ACTIVEMQ_SUNJMX_START","-Dcom.sun.management.jmxremote")
.build()))
.withCopyFileToContainer(
MountableFile.forClasspathResource("activemq/env", 0400), "/opt/activemq/bin/env")
.withFileFromClasspath("config/env", "activemq/config/env")
.withFileFromClasspath("Dockerfile", "activemq/Dockerfile"))
.withNetwork(Network.SHARED)
.withEnv("LOCAL_JMX", "no")
.withNetworkAliases("activemq")
Expand All @@ -55,12 +38,96 @@ class ActivemqIntegrationTest extends AbstractIntegrationTest {
@Test
void endToEnd() {
waitAndAssertMetrics(
metric ->
assertSumWithAttributes(
metric,
"activemq.consumer.count",
"The number of consumers currently reading from the broker.",
"{consumers}",
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.producer.count",
"The number of producers currently attached to the broker.",
"{producers}",
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))),
metric ->
assertSum(
metric,
"activemq.connection.count",
"The total number of current connections.",
"{connections}",
/* isMonotonic= */ false),
metric ->
assertGaugeWithAttributes(
metric,
"activemq.memory.usage",
"The percentage of configured memory used.",
"%",
attrs -> attrs.containsOnly(entry("destination", "client_test"))));
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))),
metric ->
assertGauge(
metric,
"activemq.disk.store_usage",
"The percentage of configured disk used for persistent messages.",
"%"),
metric ->
assertGauge(
metric,
"activemq.disk.temp_usage",
"The percentage of configured disk used for non-persistent messages.",
"%"),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.current",
"The current number of messages waiting to be consumed.",
"{messages}",
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.current",
"The current number of messages waiting to be consumed.",
"{messages}",
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.expired",
"The total number of messages not delivered because they expired.",
"{messages}",
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.enqueued",
"The total number of messages received by the broker.",
"{messages}",
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.dequeued",
"The total number of messages delivered to consumers.",
"{messages}",
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))),
metric ->
assertGaugeWithAttributes(
metric,
"activemq.message.wait_time.avg",
"The average time a message was held on a destination.",
"ms",
attrs ->
attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))));
}
}
8 changes: 8 additions & 0 deletions jmx-metrics/src/integrationTest/resources/activemq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM rmohr/activemq:5.15.9-alpine


COPY --chown=activemq config/env /opt/activemq/bin/env
ENV ACTIVEMQ_JMX=10991
EXPOSE $ACTIVEMQ_JMX

ENV ACTIVEMQ_JMX_OPTS="-Dcom.sun.management.jmxremote.port=10991 -Dcom.sun.management.jmxremote.rmi.port=10991 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
Loading

0 comments on commit e000aa8

Please sign in to comment.