Commit 51098f9
authored
Add configuration files for JMX support. (#817)
*Description of changes:*
### 1. rules/*.yaml
The [JMX Metric
Insight](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/jmx-metrics/javaagent/README.md)
and the [JMX Metric
Gatherer](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/jmx-metrics)
have different pre-defined target systems (activemq, tomcat, etc.) and
even different metrics within each shared target system
(open-telemetry/opentelemetry-java-instrumentation#9765).
This is an effort to unify the metrics being generated by deferring to
the Gatherer's definition files.
By placing it in the same path as the JMX Metric Insight resources, the
rule files can be overwritten and referred to
[directly](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/jmx-metrics/javaagent/src/main/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstaller.java#L55).
```
> gradlew build
> jar tf otelagent/build/libs/aws-opentelemetry-agent-1.33.0-SNAPSHOT.jar | grep jmx
inst/META-INF/io/opentelemetry/instrumentation/io.opentelemetry.jmx-metrics.properties
inst/io/opentelemetry/javaagent/shaded/instrumentation/javaagent/jmx/
inst/io/opentelemetry/javaagent/shaded/instrumentation/javaagent/jmx/JmxMetricInsightInstaller.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/AttributeInfo.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/BeanAttributeExtractor.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/BeanFinder$1.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/BeanFinder.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/BeanGroup.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/DetectionStatus.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/JmxMetricInsight.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricAttribute.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricAttributeExtractor.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricConfiguration.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricDef.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricExtractor.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricInfo$Type.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricInfo.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricRegistrar$1.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricRegistrar.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/JmxConfig.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/JmxRule.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/Metric.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/MetricStructure.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/RuleParser.classdata
inst/jmx/
inst/jmx/rules/
inst/jmx/rules/activemq.yaml
inst/jmx/rules/hadoop.yaml
inst/jmx/rules/jetty.yaml
inst/jmx/rules/kafka-broker.yaml
inst/jmx/rules/tomcat.yaml
inst/jmx/rules/wildfly.yaml
inst/jmx/
inst/jmx/rules/
inst/jmx/rules/jvm.yaml
inst/jmx/rules/kafka-consumer.yaml
inst/jmx/rules/kafka-producer.yaml
inst/jmx/rules/kafka.yaml
inst/jmx/rules/tomcat.yaml
inst/jmx/view.yaml
```
This makes it easier for users to specify the target systems via
environment variables.
```
OTEL_JMX_TARGET_SYSTEM: jvm, tomcat
```
This results in
```
petclinic [otel.javaagent 2024-06-14 20:27:36:575 +0000] [main] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.yaml.RuleParser - jvm: found 5 metric rules
petclinic [otel.javaagent 2024-06-14 20:27:36:607 +0000] [main] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.yaml.RuleParser - tomcat: found 6 metric rules
petclinic [otel.javaagent 2024-06-14 20:27:37:731 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.classes.loaded
petclinic [otel.javaagent 2024-06-14 20:27:37:738 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Counter for jvm.gc.collections.count
petclinic [otel.javaagent 2024-06-14 20:27:37:739 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Counter for jvm.gc.collections.elapsed
petclinic [otel.javaagent 2024-06-14 20:27:37:740 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.memory.heap
petclinic [otel.javaagent 2024-06-14 20:27:37:740 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.memory.nonheap
petclinic [otel.javaagent 2024-06-14 20:27:37:745 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.memory.pool.usage
petclinic [otel.javaagent 2024-06-14 20:27:37:745 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.threads.count
```
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.1 parent 4077ee0 commit 51098f9
File tree
5 files changed
+510
-5
lines changed- instrumentation/jmx-metrics/src/main/resources/jmx/rules
5 files changed
+510
-5
lines changedLines changed: 32 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
33 | 45 | | |
34 | 46 | | |
35 | | - | |
36 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
37 | 55 | | |
38 | 56 | | |
39 | 57 | | |
| |||
43 | 61 | | |
44 | 62 | | |
45 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
46 | 67 | | |
47 | 68 | | |
48 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
49 | 76 | | |
50 | 77 | | |
51 | 78 | | |
| |||
54 | 81 | | |
55 | 82 | | |
56 | 83 | | |
57 | | - | |
| 84 | + | |
58 | 85 | | |
59 | 86 | | |
60 | 87 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
Lines changed: 61 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
0 commit comments