From 2ae7eda3001e246b1036c588749a9eacd748f60b Mon Sep 17 00:00:00 2001 From: Findeisen Date: Tue, 15 Nov 2022 10:29:30 -0800 Subject: [PATCH] Post-review change: class renaming --- .../instrumentation/jmx/engine/BeanFinder.java | 2 +- .../jmx/engine/{BeanPack.java => BeanGroup.java} | 6 +++--- .../instrumentation/jmx/engine/MetricDef.java | 8 ++++---- .../instrumentation/jmx/yaml/JmxRule.java | 14 ++++++-------- 4 files changed, 14 insertions(+), 16 deletions(-) rename instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/{BeanPack.java => BeanGroup.java} (87%) diff --git a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanFinder.java b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanFinder.java index 827c32f400bb..fa44f293cc4e 100644 --- a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanFinder.java +++ b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanFinder.java @@ -75,7 +75,7 @@ private void refreshState() { * @param servers the list of MBeanServers to query */ private void resolveBeans(MetricDef metricDef, List servers) { - BeanPack beans = metricDef.getBeanPack(); + BeanGroup beans = metricDef.getBeanGroup(); for (MBeanServer server : servers) { // The set of all matching ObjectNames recognized by the server diff --git a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanPack.java b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanGroup.java similarity index 87% rename from instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanPack.java rename to instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanGroup.java index 8bef01c07e57..dc4fb3ef5fbb 100644 --- a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanPack.java +++ b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanGroup.java @@ -13,19 +13,19 @@ * A class describing a set of MBeans which can be used to collect values for a metric. Objects of * this class are immutable. */ -public class BeanPack { +public class BeanGroup { // How to specify the MBean(s) @Nullable private final QueryExp queryExp; private final ObjectName[] namePatterns; /** - * Constructor for BeanPack. + * Constructor for BeanGroup. * * @param queryExp the QueryExp to be used to filter results when looking for MBeans * @param namePatterns an array of ObjectNames used to look for MBeans; usually they will be * patterns. If multiple patterns are provided, they work as logical OR. */ - public BeanPack(@Nullable QueryExp queryExp, ObjectName... namePatterns) { + public BeanGroup(@Nullable QueryExp queryExp, ObjectName... namePatterns) { this.queryExp = queryExp; this.namePatterns = namePatterns; } diff --git a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricDef.java b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricDef.java index 4107a80f83e7..875e90b76cf1 100644 --- a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricDef.java +++ b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricDef.java @@ -64,14 +64,14 @@ // // MetricDef def = // new MetricDef( -// new BeanPack(null, new ObjectName("java.lang:name=*,type=MemoryPool")), +// new BeanGroup(null, new ObjectName("java.lang:name=*,type=MemoryPool")), // usageUsedExtractor, // usageMaxExtractor); public class MetricDef { // Describes the MBeans to use - private final BeanPack beans; + private final BeanGroup beans; // Describes how to get the metric values and their attributes, and how to report them private final MetricExtractor[] metricExtractors; @@ -84,12 +84,12 @@ public class MetricDef { * MetricExtractor is provided, they should use unique metric names or unique metric * attributes */ - public MetricDef(BeanPack beans, MetricExtractor... metricExtractors) { + public MetricDef(BeanGroup beans, MetricExtractor... metricExtractors) { this.beans = beans; this.metricExtractors = metricExtractors; } - BeanPack getBeanPack() { + BeanGroup getBeanGroup() { return beans; } diff --git a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/yaml/JmxRule.java b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/yaml/JmxRule.java index 3d94f490c1a7..0bb394cc05e3 100644 --- a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/yaml/JmxRule.java +++ b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/yaml/JmxRule.java @@ -6,7 +6,7 @@ package io.opentelemetry.instrumentation.jmx.yaml; import io.opentelemetry.instrumentation.jmx.engine.BeanAttributeExtractor; -import io.opentelemetry.instrumentation.jmx.engine.BeanPack; +import io.opentelemetry.instrumentation.jmx.engine.BeanGroup; import io.opentelemetry.instrumentation.jmx.engine.MetricAttribute; import io.opentelemetry.instrumentation.jmx.engine.MetricDef; import io.opentelemetry.instrumentation.jmx.engine.MetricExtractor; @@ -116,16 +116,16 @@ private static Map validateAttributeMapping(Map * @throws an exception if any issues within the rule are detected */ public MetricDef buildMetricDef() throws Exception { - BeanPack pack; + BeanGroup group; if (bean != null) { - pack = new BeanPack(null, new ObjectName(bean)); + group = new BeanGroup(null, new ObjectName(bean)); } else if (beans != null && !beans.isEmpty()) { ObjectName[] objectNames = new ObjectName[beans.size()]; int k = 0; for (String oneBean : beans) { objectNames[k++] = new ObjectName(oneBean); } - pack = new BeanPack(null, objectNames); + group = new BeanGroup(null, objectNames); } else { throw new IllegalStateException("No ObjectName specified"); } @@ -175,7 +175,7 @@ public MetricDef buildMetricDef() throws Exception { metricExtractors[n++] = metricExtractor; } - return new MetricDef(pack, metricExtractors); + return new MetricDef(group, metricExtractors); } private static List combineMetricAttributes( @@ -190,8 +190,6 @@ private static List combineMetricAttributes( set.put(metricAttribute.getAttributeName(), metricAttribute); } - List result = new ArrayList(); - result.addAll(set.values()); - return result; + return new ArrayList(set.values()); } }