Skip to content

Commit

Permalink
Post-review change: class renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterF778 committed Nov 15, 2022
1 parent ec19742 commit 2ae7eda
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void refreshState() {
* @param servers the list of MBeanServers to query
*/
private void resolveBeans(MetricDef metricDef, List<MBeanServer> servers) {
BeanPack beans = metricDef.getBeanPack();
BeanGroup beans = metricDef.getBeanGroup();

for (MBeanServer server : servers) {
// The set of all matching ObjectNames recognized by the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,16 +116,16 @@ private static Map<String, Metric> validateAttributeMapping(Map<String, Metric>
* @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");
}
Expand Down Expand Up @@ -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<MetricAttribute> combineMetricAttributes(
Expand All @@ -190,8 +190,6 @@ private static List<MetricAttribute> combineMetricAttributes(
set.put(metricAttribute.getAttributeName(), metricAttribute);
}

List<MetricAttribute> result = new ArrayList<MetricAttribute>();
result.addAll(set.values());
return result;
return new ArrayList<MetricAttribute>(set.values());
}
}

0 comments on commit 2ae7eda

Please sign in to comment.