From 8a97c480a2da7ca57228148817db1bd3589a6b13 Mon Sep 17 00:00:00 2001 From: armstrmi Date: Tue, 11 Jan 2022 14:29:09 -0500 Subject: [PATCH 01/10] wip --- jmx-metrics/docs/target-systems/activemq.md | 54 ++++++++ .../jmxmetrics/AbstractIntegrationTest.java | 2 +- .../ActivemqIntegrationTest.java | 66 ++++++++++ .../integrationTest/resources/activemq/env | 117 +++++++++++++++++ .../target-systems/activemq.properties | 7 + .../contrib/jmxmetrics/JmxConfig.java | 3 +- .../resources/target-systems/activemq.groovy | 124 ++++++++++++++++++ .../contrib/jmxmetrics/JmxConfigTest.java | 5 +- 8 files changed, 374 insertions(+), 4 deletions(-) create mode 100644 jmx-metrics/docs/target-systems/activemq.md create mode 100644 jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java create mode 100644 jmx-metrics/src/integrationTest/resources/activemq/env create mode 100644 jmx-metrics/src/integrationTest/resources/target-systems/activemq.properties create mode 100644 jmx-metrics/src/main/resources/target-systems/activemq.groovy diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md new file mode 100644 index 000000000..4cb93e8d2 --- /dev/null +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -0,0 +1,54 @@ +# ActiveMQ Metrics + +The JMX Metric Gatherer provides built in Tomcat metric gathering capabilities. +These metrics are sourced from: https://activemq.apache.org/jmx + +### Metrics + +* Name: `activemq.consumer.count` +* Description: The number of consumers currently reading from the broker. +* Unit: `{consumers}` +* Labels: `destination` +* Instrument Type: LongUpDownCounterCallback + + +* Name: `activemq.producer.count` +* Description: The number of producers currently attached to the broker. +* Unit: `{producers}` +* Labels: `destination` +* 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: `tomcat.threads` +* Description: The number of threads. +* Unit: `threads` +* Labels: `proto_handler`, `state` +* Instrument Type: LongValueCallback + + +* Name: `tomcat.max_time` +* Description: Maximum time to process a request. +* Unit: `ms` +* Labels: `proto_handler` +* Instrument Type: LongCounterCallback + + +* Name: `tomcat.request_count` +* Description: The total requests. +* Unit: `requests` +* Labels: `proto_handler` +* Instrument Type: LongCounterCallback diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java index f368ece4d..b14407abf 100644 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java +++ b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java @@ -114,7 +114,7 @@ void beforeEach() { @SafeVarargs protected final void waitAndAssertMetrics(Consumer... assertions) { await() - .atMost(Duration.ofSeconds(30)) + .atMost(Duration.ofMinutes(2)) .untilAsserted( () -> { List metrics = diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java new file mode 100644 index 000000000..14421f3be --- /dev/null +++ b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java @@ -0,0 +1,66 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.contrib.jmxmetrics.target_systems; + +import static org.assertj.core.api.Assertions.entry; + +import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; +import java.time.Duration; +import org.junit.jupiter.api.Test; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; +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 { + + ActivemqIntegrationTest() { + super(/* configFromStdin= */ false, "target-systems/activemq.properties"); + } + + @Container + 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") + .withNetwork(Network.SHARED) + .withEnv("LOCAL_JMX", "no") + .withNetworkAliases("activemq") + .withExposedPorts(10991) + .withStartupTimeout(Duration.ofMinutes(2)) + .waitingFor(Wait.forListeningPort()); + + @Test + void endToEnd() { + waitAndAssertMetrics( + metric -> + assertGaugeWithAttributes( + metric, + "activemq.memory.usage", + "The percentage of configured memory used.", + "%", + attrs -> attrs.containsOnly(entry("destination", "client_test")))); + } +} diff --git a/jmx-metrics/src/integrationTest/resources/activemq/env b/jmx-metrics/src/integrationTest/resources/activemq/env new file mode 100644 index 000000000..bfcc87c6f --- /dev/null +++ b/jmx-metrics/src/integrationTest/resources/activemq/env @@ -0,0 +1,117 @@ + #!/bin/sh + # ------------------------------------------------------------------------ + # Licensed to the Apache Software Foundation (ASF) under one or more + # contributor license agreements. See the NOTICE file distributed with + # this work for additional information regarding copyright ownership. + # The ASF licenses this file to You under the Apache License, Version 2.0 + # (the "License"); you may not use this file except in compliance with + # the License. You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # ------------------------------------------------------------------------ + # + # Configuration file for running Apache Active MQ as standalone provider. + # + # This file overwrites the predefined settings of the sysv init-script. + # You can also use alternate location for default settings - + # invoke the init-script without a argument an review help section "Configuration of this script" + # /etc/default/activemq /.activemqrc /bin/env + + # Active MQ installation dirs + # ACTIVEMQ_HOME="/" + # ACTIVEMQ_BASE="$ACTIVEMQ_HOME" + # ACTIVEMQ_CONF="$ACTIVEMQ_BASE/conf" + # ACTIVEMQ_DATA="$ACTIVEMQ_BASE/data" + # ACTIVEMQ_TMP="$ACTIVEMQ_BASE/tmp" + + # Set jvm memory configuration (minimal/maximum amount of memory) + ACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx256M" + + if [ -z "$ACTIVEMQ_OPTS" ] ; then + ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config" + fi + + if [ -z "$ACTIVEMQ_OUT" ]; then + ACTIVEMQ_OUT="/dev/null" + fi + + # Uncomment to enable audit logging + #ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS -Dorg.apache.activemq.audit=true" + + # Set jvm jmx configuration + # This enables jmx access over a configured jmx-tcp-port. + # You have to configure the first four settings if you run a ibm jvm, caused by the + # fact that IBM's jvm does not support VirtualMachine.attach(PID). + # JMX access is needed for quering a running activemq instance to gain data or to + # trigger management operations. + # + # Example for ${ACTIVEMQ_CONF}/jmx.access: + # --- + # # The "monitorRole" role has readonly access. + # # The "controlRole" role has readwrite access. + # monitorRole readonly + # controlRole readwrite + # --- + # + # Example for ${ACTIVEMQ_CONF}/jmx.password: + # --- + # # The "monitorRole" role has password "abc123". + # # # The "controlRole" role has password "abcd1234". + # monitorRole abc123 + # controlRole abcd1234 + # --- + # + # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.port=11099 " + # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONF}/jmx.password" + # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONF}/jmx.access" + # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false" + # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote" + ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote" + + # Set jvm jmx configuration for controlling the broker process + # You only have to configure the first four settings if you run a ibm jvm, caused by the + # fact that IBM's jvm does not support VirtualMachine.attach(PID) + # (see also com.sun.management.jmxremote.port, .jmx.password.file and .jmx.access.file ) + #ACTIVEMQ_SUNJMX_CONTROL="--jmxurl service:jmx:rmi:///jndi/rmi://127.0.0.1:1099/jmxrmi --jmxuser controlRole --jmxpassword abcd1234" + ACTIVEMQ_SUNJMX_CONTROL="" + + # Specify the queue manager URL for using "browse" option of sysv initscript + if [ -z "$ACTIVEMQ_QUEUEMANAGERURL" ]; then + ACTIVEMQ_QUEUEMANAGERURL="--amqurl tcp://localhost:61616" + fi + + # Set additional JSE arguments + if [ -z "$ACTIVEMQ_SSL_OPTS" ] ; then + #ACTIVEMQ_SSL_OPTS="-Djava.security.properties=$ACTIVEMQ_CONF/java.security" + ACTIVEMQ_SSL_OPTS="" + fi + + # Uncomment to enable remote debugging + #ACTIVEMQ_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" + + # ActiveMQ tries to shutdown the broker by jmx, + # after a specified number of seconds send SIGKILL + if [ -z "$ACTIVEMQ_KILL_MAXSECONDS" ]; then + ACTIVEMQ_KILL_MAXSECONDS=30 + fi + + # Configure a user with non root privileges, if no user is specified do not change user + # (the entire activemq installation should be owned by this user) + ACTIVEMQ_USER="" + + # location of the pidfile + # ACTIVEMQ_PIDFILE="$ACTIVEMQ_DATA/activemq.pid" + + # Location of the java installation + # Specify the location of your java installation using JAVA_HOME, or specify the + # path to the "java" binary using JAVACMD + # (set JAVACMD to "auto" for automatic detection) + #JAVA_HOME="" + JAVACMD="auto" + ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $ACTIVEMQ_JMX_OPTS -Dhawtio.authenticationEnabled=false -Dhawtio.realm=activemq -Dhawtio.role=admins -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal" diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/activemq.properties b/jmx-metrics/src/integrationTest/resources/target-systems/activemq.properties new file mode 100644 index 000000000..e69b6ba2e --- /dev/null +++ b/jmx-metrics/src/integrationTest/resources/target-systems/activemq.properties @@ -0,0 +1,7 @@ +otel.jmx.interval.milliseconds = 3000 +otel.metrics.exporter = otlp +otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://activemq:10991/jmxrmi +otel.jmx.target.system = activemq + +# these will be overridden by cmd line +otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/JmxConfig.java b/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/JmxConfig.java index 29789d1c5..dbf630d76 100644 --- a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/JmxConfig.java +++ b/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/JmxConfig.java @@ -33,7 +33,8 @@ class JmxConfig { static final String JMX_REALM = PREFIX + "jmx.realm"; static final List AVAILABLE_TARGET_SYSTEMS = - Arrays.asList("cassandra", "jvm", "kafka", "kafka-consumer", "kafka-producer", "tomcat"); + Arrays.asList( + "cassandra", "jvm", "kafka", "kafka-consumer", "kafka-producer", "tomcat", "activemq"); final String serviceUrl; final String groovyScript; diff --git a/jmx-metrics/src/main/resources/target-systems/activemq.groovy b/jmx-metrics/src/main/resources/target-systems/activemq.groovy new file mode 100644 index 000000000..cce7c5046 --- /dev/null +++ b/jmx-metrics/src/main/resources/target-systems/activemq.groovy @@ -0,0 +1,124 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +def activemqMetrics = otel.mbeans( + [ + "org.apache.activemq:type=Broker,brokerName=*,destinationType=Queue,destinationName=*", + "org.apache.activemq:type=Broker,brokerName=*,destinationType=Topic,destinationName=*" + ] +) + + +otel.instrument(activemqMetrics, + "activemq.producer.count", + "The number of producers currently attached to the broker.", + "{producers}", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "ProducerCount", + otel.&longUpDownCounterCallback) +// +//otel.instrument(activemqMetrics, +// "activemq.consumer.count", +// "The number of consumers currently reading from the broker.", +// "{consumers}", +// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], +// "ConsumerCount", +// otel.&longUpDownCounterCallback) +// +//otel.instrument(activemqMetrics, +// "activemq.memory.usage", +// "The percentage of configured memory used.", +// "%", +// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], +// "MemoryPercentUsage", +// otel.&doubleValueCallback) +// +//otel.instrument(activemqMetrics, +// "activemq.memory.usage", +// "The percentage of configured memory used.", +// "%", +// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], +// "MemoryPercentUsage", +// otel.&doubleValueCallback) +// +//otel.instrument(activemqMetrics, +// "activemq.message.current", +// "The current number of messages waiting to be consumed.", +// "{messages}", +// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], +// "QueueSize", +// otel.&longUpDownCounterCallback) +// +//otel.instrument(activemqMetrics, +// "activemq.message.expired", +// "The total number of messages not delivered because they expired.", +// "{messages}", +// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], +// "ExpiredCount", +// otel.&longCounterCallback) +// +//otel.instrument(activemqMetrics, +// "activemq.message.enqueued", +// "The total number of messages received by the broker.", +// "{messages}", +// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], +// "EnqueueCount", +// otel.&longCounterCallback) +// +//otel.instrument(activemqMetrics, +// "activemq.message.dequeued", +// "The total number of messages delivered to consumers.", +// "{messages}", +// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], +// "DequeueCount", +// otel.&longCounterCallback) +// +//otel.instrument(activemqMetrics, +// "activemq.message.wait_time.avg", +// "The average time a message was held on a destination.", +// "ms", +// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], +// "AverageEnqueueTime", +// otel.&doubleValueCallback) +// +// +// +// +//def activemqMetricsNoDestination = otel.mbean( +// "org.apache.activemq:type=Broker,brokerName=*" +//) +// +//otel.instrument(activemqMetricsNoDestination, +// "activemq.connection.count", +// "The total number of current connections.", +// "{connections}", +// "CurrentConnectionsCount", +// otel.&longUpDownCounterCallback) +// +//otel.instrument(activemqMetricsNoDestination, +// "activemq.disk.store_usage", +// "The percentage of configured disk used for persistent messages.", +// "%", +// "StorePercentUsage", +// otel.&doubleValueCallback) +// +//otel.instrument(activemqMetricsNoDestination, +// "activemq.disk.temp_usage", +// "The percentage of configured disk used for non-persistent messages.", +// "%", +// "TempPercentUsage", +// otel.&doubleValueCallback) \ No newline at end of file diff --git a/jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/JmxConfigTest.java b/jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/JmxConfigTest.java index 8a2cdc600..42c5ecd74 100644 --- a/jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/JmxConfigTest.java +++ b/jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/JmxConfigTest.java @@ -16,7 +16,8 @@ class JmxConfigTest { @Test void staticValues() { assertThat(JmxConfig.AVAILABLE_TARGET_SYSTEMS) - .containsOnly("cassandra", "jvm", "kafka", "kafka-consumer", "kafka-producer", "tomcat"); + .containsOnly( + "cassandra", "jvm", "kafka", "kafka-consumer", "kafka-producer", "tomcat", "activemq"); } @Test @@ -114,6 +115,6 @@ void invalidTargetSystem() { .isInstanceOf(ConfigurationException.class) .hasMessage( "[jvm, unavailabletargetsystem] must specify targets from " - + "[cassandra, jvm, kafka, kafka-consumer, kafka-producer, tomcat]"); + + "[cassandra, jvm, kafka, kafka-consumer, kafka-producer, tomcat, activemq]"); } } From e000aa80be6b297a9c7b85397242c0c3ab1a9902 Mon Sep 17 00:00:00 2001 From: armstrmi Date: Thu, 13 Jan 2022 14:33:09 -0500 Subject: [PATCH 02/10] Added activeMQ update --- jmx-metrics/docs/target-systems/activemq.md | 61 ++++-- .../jmxmetrics/AbstractIntegrationTest.java | 2 +- .../ActivemqIntegrationTest.java | 107 +++++++++-- .../resources/activemq/Dockerfile | 8 + .../resources/activemq/{ => config}/env | 0 .../resources/target-systems/activemq.groovy | 176 +++++++++--------- 6 files changed, 223 insertions(+), 131 deletions(-) create mode 100644 jmx-metrics/src/integrationTest/resources/activemq/Dockerfile rename jmx-metrics/src/integrationTest/resources/activemq/{ => config}/env (100%) diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md index 4cb93e8d2..c4aa95667 100644 --- a/jmx-metrics/docs/target-systems/activemq.md +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -19,6 +19,12 @@ 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: `%` @@ -26,29 +32,48 @@ These metrics are sourced from: https://activemq.apache.org/jmx * 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 diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java index b14407abf..f368ece4d 100644 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java +++ b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java @@ -114,7 +114,7 @@ void beforeEach() { @SafeVarargs protected final void waitAndAssertMetrics(Consumer... assertions) { await() - .atMost(Duration.ofMinutes(2)) + .atMost(Duration.ofSeconds(30)) .untilAsserted( () -> { List metrics = diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java index 14421f3be..9a453d222 100644 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java +++ b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java @@ -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 { @@ -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") @@ -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")))); } } diff --git a/jmx-metrics/src/integrationTest/resources/activemq/Dockerfile b/jmx-metrics/src/integrationTest/resources/activemq/Dockerfile new file mode 100644 index 000000000..be578bf61 --- /dev/null +++ b/jmx-metrics/src/integrationTest/resources/activemq/Dockerfile @@ -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" diff --git a/jmx-metrics/src/integrationTest/resources/activemq/env b/jmx-metrics/src/integrationTest/resources/activemq/config/env similarity index 100% rename from jmx-metrics/src/integrationTest/resources/activemq/env rename to jmx-metrics/src/integrationTest/resources/activemq/config/env diff --git a/jmx-metrics/src/main/resources/target-systems/activemq.groovy b/jmx-metrics/src/main/resources/target-systems/activemq.groovy index cce7c5046..05365d984 100644 --- a/jmx-metrics/src/main/resources/target-systems/activemq.groovy +++ b/jmx-metrics/src/main/resources/target-systems/activemq.groovy @@ -30,95 +30,87 @@ otel.instrument(activemqMetrics, ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], "ProducerCount", otel.&longUpDownCounterCallback) -// -//otel.instrument(activemqMetrics, -// "activemq.consumer.count", -// "The number of consumers currently reading from the broker.", -// "{consumers}", -// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], -// "ConsumerCount", -// otel.&longUpDownCounterCallback) -// -//otel.instrument(activemqMetrics, -// "activemq.memory.usage", -// "The percentage of configured memory used.", -// "%", -// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], -// "MemoryPercentUsage", -// otel.&doubleValueCallback) -// -//otel.instrument(activemqMetrics, -// "activemq.memory.usage", -// "The percentage of configured memory used.", -// "%", -// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], -// "MemoryPercentUsage", -// otel.&doubleValueCallback) -// -//otel.instrument(activemqMetrics, -// "activemq.message.current", -// "The current number of messages waiting to be consumed.", -// "{messages}", -// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], -// "QueueSize", -// otel.&longUpDownCounterCallback) -// -//otel.instrument(activemqMetrics, -// "activemq.message.expired", -// "The total number of messages not delivered because they expired.", -// "{messages}", -// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], -// "ExpiredCount", -// otel.&longCounterCallback) -// -//otel.instrument(activemqMetrics, -// "activemq.message.enqueued", -// "The total number of messages received by the broker.", -// "{messages}", -// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], -// "EnqueueCount", -// otel.&longCounterCallback) -// -//otel.instrument(activemqMetrics, -// "activemq.message.dequeued", -// "The total number of messages delivered to consumers.", -// "{messages}", -// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], -// "DequeueCount", -// otel.&longCounterCallback) -// -//otel.instrument(activemqMetrics, -// "activemq.message.wait_time.avg", -// "The average time a message was held on a destination.", -// "ms", -// ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], -// "AverageEnqueueTime", -// otel.&doubleValueCallback) -// -// -// -// -//def activemqMetricsNoDestination = otel.mbean( -// "org.apache.activemq:type=Broker,brokerName=*" -//) -// -//otel.instrument(activemqMetricsNoDestination, -// "activemq.connection.count", -// "The total number of current connections.", -// "{connections}", -// "CurrentConnectionsCount", -// otel.&longUpDownCounterCallback) -// -//otel.instrument(activemqMetricsNoDestination, -// "activemq.disk.store_usage", -// "The percentage of configured disk used for persistent messages.", -// "%", -// "StorePercentUsage", -// otel.&doubleValueCallback) -// -//otel.instrument(activemqMetricsNoDestination, -// "activemq.disk.temp_usage", -// "The percentage of configured disk used for non-persistent messages.", -// "%", -// "TempPercentUsage", -// otel.&doubleValueCallback) \ No newline at end of file + +otel.instrument(activemqMetrics, + "activemq.consumer.count", + "The number of consumers currently reading from the broker.", + "{consumers}", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "ConsumerCount", + otel.&longUpDownCounterCallback) + +otel.instrument(activemqMetrics, + "activemq.memory.usage", + "The percentage of configured memory used.", + "%", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "MemoryPercentUsage", + otel.&doubleValueCallback) + +otel.instrument(activemqMetrics, + "activemq.message.current", + "The current number of messages waiting to be consumed.", + "{messages}", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "QueueSize", + otel.&longUpDownCounterCallback) + +otel.instrument(activemqMetrics, + "activemq.message.expired", + "The total number of messages not delivered because they expired.", + "{messages}", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "ExpiredCount", + otel.&longCounterCallback) + +otel.instrument(activemqMetrics, + "activemq.message.enqueued", + "The total number of messages received by the broker.", + "{messages}", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "EnqueueCount", + otel.&longCounterCallback) + +otel.instrument(activemqMetrics, + "activemq.message.dequeued", + "The total number of messages delivered to consumers.", + "{messages}", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "DequeueCount", + otel.&longCounterCallback) + +otel.instrument(activemqMetrics, + "activemq.message.wait_time.avg", + "The average time a message was held on a destination.", + "ms", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "AverageEnqueueTime", + otel.&doubleValueCallback) + + + + +def activemqMetricsNoDestination = otel.mbean( + "org.apache.activemq:type=Broker,brokerName=*" +) + +otel.instrument(activemqMetricsNoDestination, + "activemq.connection.count", + "The total number of current connections.", + "{connections}", + "CurrentConnectionsCount", + otel.&longUpDownCounterCallback) + +otel.instrument(activemqMetricsNoDestination, + "activemq.disk.store_usage", + "The percentage of configured disk used for persistent messages.", + "%", + "StorePercentUsage", + otel.&doubleValueCallback) + +otel.instrument(activemqMetricsNoDestination, + "activemq.disk.temp_usage", + "The percentage of configured disk used for non-persistent messages.", + "%", + "TempPercentUsage", + otel.&doubleValueCallback) \ No newline at end of file From db28fc39082de395c17637c8fb3b5eaf971359de Mon Sep 17 00:00:00 2001 From: armstrmi Date: Thu, 13 Jan 2022 15:45:18 -0500 Subject: [PATCH 03/10] updated docs --- jmx-metrics/docs/target-systems/activemq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md index c4aa95667..4a41b1b61 100644 --- a/jmx-metrics/docs/target-systems/activemq.md +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -1,6 +1,6 @@ # ActiveMQ Metrics -The JMX Metric Gatherer provides built in Tomcat metric gathering capabilities. +The JMX Metric Gatherer provides built in ActiveMQ metric gathering capabilities. These metrics are sourced from: https://activemq.apache.org/jmx ### Metrics From 0a5815d0233e3dd0304244de3855c33a0a394b6b Mon Sep 17 00:00:00 2001 From: armstrmi Date: Fri, 14 Jan 2022 10:12:23 -0500 Subject: [PATCH 04/10] implemented changes recommended by pr review --- jmx-metrics/docs/target-systems/activemq.md | 26 ++++++------- .../ActivemqIntegrationTest.java | 34 ++++++++--------- .../contrib/jmxmetrics/JmxConfig.java | 2 +- .../resources/target-systems/activemq.groovy | 38 +++++++++++-------- .../contrib/jmxmetrics/JmxConfigTest.java | 4 +- 5 files changed, 56 insertions(+), 48 deletions(-) diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md index 4a41b1b61..db2905c96 100644 --- a/jmx-metrics/docs/target-systems/activemq.md +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -1,6 +1,6 @@ # ActiveMQ Metrics -The JMX Metric Gatherer provides built in ActiveMQ metric gathering capabilities. +The [JMX Metric Gatherer]( https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/jmx-metrics/README.md#target-systems) provides built in ActiveMQ metric gathering capabilities. These metrics are sourced from: https://activemq.apache.org/jmx ### Metrics @@ -9,71 +9,71 @@ These metrics are sourced from: https://activemq.apache.org/jmx * Description: The number of consumers currently reading from the broker. * Unit: `{consumers}` * Labels: `destination` -* Instrument Type: LongUpDownCounterCallback +* Instrument Type: ObservableLongUpDownCounter * Name: `activemq.producer.count` * Description: The number of producers currently attached to the broker. * Unit: `{producers}` * Labels: `destination` -* Instrument Type: LongUpDownCounterCallback +* Instrument Type: ObservableLongUpDownCounter * Name: `activemq.connection.count` * Description: The total number of current connections. * Unit: `{connections}` -* Instrument Type: LongUpDownCounterCallback +* Instrument Type: ObservableLongUpDownCounter * Name: `activemq.memory.usage` * Description: The percentage of configured memory used. * Unit: `%` * Labels: `destination` -* Instrument Type: DoubleValueCallback +* Instrument Type: ObservableDoubleValue * Name: `activemq.disk.store_usage` * Description: The percentage of configured disk used for persistent messages. * Unit: `%` -* Instrument Type: DoubleValueCallback +* Instrument Type: ObservableDoubleValue * Name: `activemq.disk.temp_usage` * Description: The percentage of configured disk used for non-persistent messages. * Unit: `%` -* Instrument Type: DoubleValueCallback +* Instrument Type: ObservableDoubleValue * Name: `activemq.message.current` * Description: The current number of messages waiting to be consumed. * Unit: `messages` * Labels: `destination` -* Instrument Type: LongUpDownCounterCallback +* Instrument Type: ObservableLongUpDownCounter * Name: `activemq.message.expired` * Description: The total number of messages not delivered because they expired. * Unit: `messages` * Labels: `destination` -* Instrument Type: LongCounterCallback +* Instrument Type: ObservableLongCounter * Name: `activemq.message.enqueued` * Description: The total number of messages received by the broker. * Unit: `messages` * Labels: `destination` -* Instrument Type: LongCounterCallback +* Instrument Type: ObservableLongCounter * Name: `activemq.message.dequeued` * Description: The total number of messages delivered to consumers. * Unit: `messages` * Labels: `destination` -* Instrument Type: LongCounterCallback +* Instrument Type: ObservableLongCounter -* Name: `activemq.wait_time.avg` +* Name: `activemq.message.wait_time.avg` * Description: The average time a message was held on a destination. * Unit: `ms` * Labels: `destination` -* Instrument Type: DoubleValueCallback +* Instrument Type: ObservableDoubleValue \ No newline at end of file diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java index 9a453d222..c63d23836 100644 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java +++ b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java @@ -43,23 +43,23 @@ void endToEnd() { metric, "activemq.consumer.count", "The number of consumers currently reading from the broker.", - "{consumers}", + "consumers", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))), + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, "activemq.producer.count", "The number of producers currently attached to the broker.", - "{producers}", + "producers", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))), + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), metric -> assertSum( metric, "activemq.connection.count", "The total number of current connections.", - "{connections}", + "connections", /* isMonotonic= */ false), metric -> assertGaugeWithAttributes( @@ -68,7 +68,7 @@ void endToEnd() { "The percentage of configured memory used.", "%", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))), + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), metric -> assertGauge( metric, @@ -86,41 +86,41 @@ void endToEnd() { metric, "activemq.message.current", "The current number of messages waiting to be consumed.", - "{messages}", + "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))), + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, "activemq.message.current", "The current number of messages waiting to be consumed.", - "{messages}", + "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))), + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, "activemq.message.expired", "The total number of messages not delivered because they expired.", - "{messages}", + "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))), + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, "activemq.message.enqueued", "The total number of messages received by the broker.", - "{messages}", + "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))), + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, "activemq.message.dequeued", "The total number of messages delivered to consumers.", - "{messages}", + "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"))), + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), metric -> assertGaugeWithAttributes( metric, @@ -128,6 +128,6 @@ void endToEnd() { "The average time a message was held on a destination.", "ms", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker")))); + attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost")))); } } diff --git a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/JmxConfig.java b/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/JmxConfig.java index dbf630d76..2cb273dcc 100644 --- a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/JmxConfig.java +++ b/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/JmxConfig.java @@ -34,7 +34,7 @@ class JmxConfig { static final List AVAILABLE_TARGET_SYSTEMS = Arrays.asList( - "cassandra", "jvm", "kafka", "kafka-consumer", "kafka-producer", "tomcat", "activemq"); + "activemq", "cassandra", "jvm", "kafka", "kafka-consumer", "kafka-producer", "tomcat"); final String serviceUrl; final String groovyScript; diff --git a/jmx-metrics/src/main/resources/target-systems/activemq.groovy b/jmx-metrics/src/main/resources/target-systems/activemq.groovy index 05365d984..4be94529c 100644 --- a/jmx-metrics/src/main/resources/target-systems/activemq.groovy +++ b/jmx-metrics/src/main/resources/target-systems/activemq.groovy @@ -26,16 +26,18 @@ def activemqMetrics = otel.mbeans( otel.instrument(activemqMetrics, "activemq.producer.count", "The number of producers currently attached to the broker.", - "{producers}", - ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "producers", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName")}, + "broker" : { mbean -> mbean.name().getKeyProperty("brokerName")}], "ProducerCount", otel.&longUpDownCounterCallback) otel.instrument(activemqMetrics, "activemq.consumer.count", "The number of consumers currently reading from the broker.", - "{consumers}", - ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "consumers", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }, + "broker" : { mbean -> mbean.name().getKeyProperty("brokerName")}], "ConsumerCount", otel.&longUpDownCounterCallback) @@ -43,39 +45,44 @@ otel.instrument(activemqMetrics, "activemq.memory.usage", "The percentage of configured memory used.", "%", - ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }, + "broker" : { mbean -> mbean.name().getKeyProperty("brokerName")}], "MemoryPercentUsage", otel.&doubleValueCallback) otel.instrument(activemqMetrics, "activemq.message.current", "The current number of messages waiting to be consumed.", - "{messages}", - ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "messages", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }, + "broker" : { mbean -> mbean.name().getKeyProperty("brokerName")}], "QueueSize", otel.&longUpDownCounterCallback) otel.instrument(activemqMetrics, "activemq.message.expired", "The total number of messages not delivered because they expired.", - "{messages}", - ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "messages", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }, + "broker" : { mbean -> mbean.name().getKeyProperty("brokerName")}], "ExpiredCount", otel.&longCounterCallback) otel.instrument(activemqMetrics, "activemq.message.enqueued", "The total number of messages received by the broker.", - "{messages}", - ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "messages", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }, + "broker" : { mbean -> mbean.name().getKeyProperty("brokerName")}], "EnqueueCount", otel.&longCounterCallback) otel.instrument(activemqMetrics, "activemq.message.dequeued", "The total number of messages delivered to consumers.", - "{messages}", - ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + "messages", + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }, + "broker" : { mbean -> mbean.name().getKeyProperty("brokerName")}], "DequeueCount", otel.&longCounterCallback) @@ -83,7 +90,8 @@ otel.instrument(activemqMetrics, "activemq.message.wait_time.avg", "The average time a message was held on a destination.", "ms", - ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }], + ["destination" : { mbean -> mbean.name().getKeyProperty("destinationName") }, + "broker" : { mbean -> mbean.name().getKeyProperty("brokerName")}], "AverageEnqueueTime", otel.&doubleValueCallback) @@ -97,7 +105,7 @@ def activemqMetricsNoDestination = otel.mbean( otel.instrument(activemqMetricsNoDestination, "activemq.connection.count", "The total number of current connections.", - "{connections}", + "connections", "CurrentConnectionsCount", otel.&longUpDownCounterCallback) diff --git a/jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/JmxConfigTest.java b/jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/JmxConfigTest.java index 42c5ecd74..cbcba6bcd 100644 --- a/jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/JmxConfigTest.java +++ b/jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/JmxConfigTest.java @@ -17,7 +17,7 @@ class JmxConfigTest { void staticValues() { assertThat(JmxConfig.AVAILABLE_TARGET_SYSTEMS) .containsOnly( - "cassandra", "jvm", "kafka", "kafka-consumer", "kafka-producer", "tomcat", "activemq"); + "activemq", "cassandra", "jvm", "kafka", "kafka-consumer", "kafka-producer", "tomcat"); } @Test @@ -115,6 +115,6 @@ void invalidTargetSystem() { .isInstanceOf(ConfigurationException.class) .hasMessage( "[jvm, unavailabletargetsystem] must specify targets from " - + "[cassandra, jvm, kafka, kafka-consumer, kafka-producer, tomcat, activemq]"); + + "[activemq, cassandra, jvm, kafka, kafka-consumer, kafka-producer, tomcat]"); } } From 6476e97ddf9182c383a25e6696174488faab707d Mon Sep 17 00:00:00 2001 From: armstrmi Date: Fri, 14 Jan 2022 10:29:11 -0500 Subject: [PATCH 05/10] updated docs to remove curly braces --- jmx-metrics/docs/target-systems/activemq.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md index db2905c96..22cd3438f 100644 --- a/jmx-metrics/docs/target-systems/activemq.md +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -7,21 +7,21 @@ These metrics are sourced from: https://activemq.apache.org/jmx * Name: `activemq.consumer.count` * Description: The number of consumers currently reading from the broker. -* Unit: `{consumers}` +* Unit: `consumers` * Labels: `destination` * Instrument Type: ObservableLongUpDownCounter * Name: `activemq.producer.count` * Description: The number of producers currently attached to the broker. -* Unit: `{producers}` +* Unit: `producers` * Labels: `destination` * Instrument Type: ObservableLongUpDownCounter -* Name: `activemq.connection.count` +* Name: `activemq.connectin.count` * Description: The total number of current connections. -* Unit: `{connections}` +* Unit: `connections` * Instrument Type: ObservableLongUpDownCounter From a71650b9b083046a6d36a56263e30609206e29f8 Mon Sep 17 00:00:00 2001 From: armstrmi Date: Fri, 14 Jan 2022 10:34:34 -0500 Subject: [PATCH 06/10] spotless check --- jmx-metrics/docs/target-systems/activemq.md | 2 +- .../ActivemqIntegrationTest.java | 36 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md index 22cd3438f..ff9a33c19 100644 --- a/jmx-metrics/docs/target-systems/activemq.md +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -76,4 +76,4 @@ These metrics are sourced from: https://activemq.apache.org/jmx * Description: The average time a message was held on a destination. * Unit: `ms` * Labels: `destination` -* Instrument Type: ObservableDoubleValue \ No newline at end of file +* Instrument Type: ObservableDoubleValue diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java index c63d23836..2bbb46bc7 100644 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java +++ b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java @@ -45,7 +45,9 @@ void endToEnd() { "The number of consumers currently reading from the broker.", "consumers", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, @@ -53,7 +55,9 @@ void endToEnd() { "The number of producers currently attached to the broker.", "producers", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost"))), metric -> assertSum( metric, @@ -68,7 +72,9 @@ void endToEnd() { "The percentage of configured memory used.", "%", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost"))), metric -> assertGauge( metric, @@ -88,7 +94,9 @@ void endToEnd() { "The current number of messages waiting to be consumed.", "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, @@ -96,7 +104,9 @@ void endToEnd() { "The current number of messages waiting to be consumed.", "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, @@ -104,7 +114,9 @@ void endToEnd() { "The total number of messages not delivered because they expired.", "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, @@ -112,7 +124,9 @@ void endToEnd() { "The total number of messages received by the broker.", "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost"))), metric -> assertSumWithAttributes( metric, @@ -120,7 +134,9 @@ void endToEnd() { "The total number of messages delivered to consumers.", "messages", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost"))), + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost"))), metric -> assertGaugeWithAttributes( metric, @@ -128,6 +144,8 @@ void endToEnd() { "The average time a message was held on a destination.", "ms", attrs -> - attrs.containsOnly(entry("destination", "ActiveMQ.Advisory.MasterBroker"),entry("broker", "localhost")))); + attrs.containsOnly( + entry("destination", "ActiveMQ.Advisory.MasterBroker"), + entry("broker", "localhost")))); } } From 1b435080240db6f326103bbd2fbb263892f88c22 Mon Sep 17 00:00:00 2001 From: armstrmi Date: Fri, 14 Jan 2022 11:05:29 -0500 Subject: [PATCH 07/10] added activemq to list --- jmx-metrics/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jmx-metrics/README.md b/jmx-metrics/README.md index c553a9025..2bf7fde78 100644 --- a/jmx-metrics/README.md +++ b/jmx-metrics/README.md @@ -69,6 +69,7 @@ mutually exclusive with `otel.jmx.groovy.script`. The currently supported target | `otel.jmx.target.system` | | ------------------------ | | [`jvm`](./docs/target-systems/jvm.md) | +| [`activemq`](./docs/target-systems/activemq.md)| | [`cassandra`](./docs/target-systems/cassandra.md) | | [`kafka`](./docs/target-systems/kafka.md) | | [`kafka-consumer`](./docs/target-systems/kafka-consumer.md) | From 1d9f4df7e8be1ab952c5dba23d56b890bc281da3 Mon Sep 17 00:00:00 2001 From: armstrmi Date: Tue, 18 Jan 2022 09:55:05 -0500 Subject: [PATCH 08/10] fixed incorrect link --- jmx-metrics/docs/target-systems/activemq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md index ff9a33c19..843749f65 100644 --- a/jmx-metrics/docs/target-systems/activemq.md +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -1,6 +1,6 @@ # ActiveMQ Metrics -The [JMX Metric Gatherer]( https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/jmx-metrics/README.md#target-systems) provides built in ActiveMQ metric gathering capabilities. +The JMX Metric Gatherer provides built in ActiveMQ metric gathering capabilities. These metrics are sourced from: https://activemq.apache.org/jmx ### Metrics From 225d37719535c1fa198eed588f11862ce8c8b250 Mon Sep 17 00:00:00 2001 From: armstrmi Date: Tue, 18 Jan 2022 12:03:35 -0500 Subject: [PATCH 09/10] forced reset --- jmx-metrics/docs/target-systems/activemq.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md index 843749f65..3061b3308 100644 --- a/jmx-metrics/docs/target-systems/activemq.md +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -77,3 +77,4 @@ These metrics are sourced from: https://activemq.apache.org/jmx * Unit: `ms` * Labels: `destination` * Instrument Type: ObservableDoubleValue + \ No newline at end of file From 06b823423f34b952496c27270ce817d35e23971e Mon Sep 17 00:00:00 2001 From: armstrmi Date: Tue, 18 Jan 2022 12:06:12 -0500 Subject: [PATCH 10/10] forced reset --- jmx-metrics/docs/target-systems/activemq.md | 1 - 1 file changed, 1 deletion(-) diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md index 3061b3308..843749f65 100644 --- a/jmx-metrics/docs/target-systems/activemq.md +++ b/jmx-metrics/docs/target-systems/activemq.md @@ -77,4 +77,3 @@ These metrics are sourced from: https://activemq.apache.org/jmx * Unit: `ms` * Labels: `destination` * Instrument Type: ObservableDoubleValue - \ No newline at end of file