Skip to content

Commit 5e69a82

Browse files
committed
rename attribute set -> group
1 parent 45ba126 commit 5e69a82

File tree

8 files changed

+67
-68
lines changed

8 files changed

+67
-68
lines changed

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/assertions/AttributeMatcher.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package io.opentelemetry.contrib.jmxscraper.assertions;
77

8-
import java.util.Objects;
98
import javax.annotation.Nullable;
109

1110
/** Implements functionality of matching data point attributes. */
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@
99
import java.util.Map;
1010
import java.util.stream.Collectors;
1111

12-
/** Holder class for a set of attribute matchers */
13-
public class AttributeMatcherSet {
12+
/** Group of attribute matchers */
13+
public class AttributeMatcherGroup {
1414

1515
// stored as a Map for easy lookup by name
1616
private final Map<String, AttributeMatcher> matchers;
1717

1818
/**
1919
* Constructor for a set of attribute matchers
2020
*
21-
* @param matchers collection of matchers to build a set from
21+
* @param matchers collection of matchers to build a group from
2222
* @throws IllegalStateException if there is any duplicate key
2323
*/
24-
AttributeMatcherSet(Collection<AttributeMatcher> matchers) {
24+
AttributeMatcherGroup(Collection<AttributeMatcher> matchers) {
2525
this.matchers =
2626
matchers.stream().collect(Collectors.toMap(AttributeMatcher::getAttributeName, m -> m));
2727
}
2828

2929
/**
30-
* Checks if attributes match this attribute matcher set
30+
* Checks if attributes match this attribute matcher group
3131
*
3232
* @param attributes attributes to check as map
33-
* @return {@literal true} when the attributes match all attributes from this set
33+
* @return {@literal true} when the attributes match all attributes from this group
3434
*/
3535
public boolean matches(Map<String, String> attributes) {
3636
if (attributes.size() != matchers.size()) {

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/assertions/DataPointAttributes.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ public static AttributeMatcher attributeWithAnyValue(String name) {
3838
}
3939

4040
/**
41-
* Create a set of attribute matchers that should be used to verify set of data point attributes.
41+
* Creates a group of attribute matchers that should be used to verify data point attributes.
4242
*
43-
* @param attributes list of matchers to create set. It must contain matchers with unique names.
44-
* @return set of unique attribute matchers
43+
* @param attributes list of matchers to create group. It must contain matchers with unique names.
44+
* @return group of attribute matchers
4545
* @throws IllegalArgumentException if provided list contains two or more matchers with the same
46-
* name.
47-
* @see MetricAssert#hasDataPointsWithAttributes(AttributeMatcherSet...) for detailed description
48-
* off the algorithm used for matching
46+
* attribute name
47+
* @see MetricAssert#hasDataPointsWithAttributes(AttributeMatcherGroup...) for detailed
48+
* description off the algorithm used for matching
4949
*/
50-
public static AttributeMatcherSet attributeSet(AttributeMatcher... attributes) {
51-
return new AttributeMatcherSet(Arrays.asList(attributes));
50+
public static AttributeMatcherGroup attributeGroup(AttributeMatcher... attributes) {
51+
return new AttributeMatcherGroup(Arrays.asList(attributes));
5252
}
5353
}

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/assertions/MetricAssert.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package io.opentelemetry.contrib.jmxscraper.assertions;
77

8-
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeSet;
8+
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeGroup;
99

1010
import com.google.errorprone.annotations.CanIgnoreReturnValue;
1111
import io.opentelemetry.proto.common.v1.KeyValue;
@@ -241,26 +241,26 @@ private void dataPointsCommonCheck(List<NumberDataPoint> dataPoints) {
241241
*/
242242
@CanIgnoreReturnValue
243243
public final MetricAssert hasDataPointsWithOneAttribute(AttributeMatcher expectedAttribute) {
244-
return hasDataPointsWithAttributes(attributeSet(expectedAttribute));
244+
return hasDataPointsWithAttributes(attributeGroup(expectedAttribute));
245245
}
246246

247247
/**
248-
* Verifies that every data point attributes set is matched exactly by one of the matcher sets
249-
* provided. Also, each matcher set must match at least one data point attributes set. Data point
250-
* attributes set is matched by matcher set if each attribute is matched by one matcher and each
251-
* matcher matches one attribute. In other words: number of attributes is the same as number of
252-
* matchers and there is 1:1 matching between them.
248+
* Verifies that every data point attributes is matched exactly by one of the matcher groups
249+
* provided. Also, each matcher group must match at least one data point attributes set. Data
250+
* point attributes are matched by matcher group if each attribute is matched by one matcher and
251+
* each matcher matches one attribute. In other words: number of attributes is the same as number
252+
* of matchers and there is 1:1 matching between them.
253253
*
254-
* @param attributeMatchers array of attribute matcher sets
254+
* @param matcherGroups array of attribute matcher groups
255255
* @return this
256256
*/
257257
@CanIgnoreReturnValue
258-
public final MetricAssert hasDataPointsWithAttributes(AttributeMatcherSet... attributeMatchers) {
258+
public final MetricAssert hasDataPointsWithAttributes(AttributeMatcherGroup... matcherGroups) {
259259
return checkDataPoints(
260260
dataPoints -> {
261261
dataPointsCommonCheck(dataPoints);
262262

263-
boolean[] matchedSets = new boolean[attributeMatchers.length];
263+
boolean[] matchedSets = new boolean[matcherGroups.length];
264264

265265
// validate each datapoint attributes match exactly one of the provided attributes sets
266266
for (NumberDataPoint dataPoint : dataPoints) {
@@ -269,24 +269,24 @@ public final MetricAssert hasDataPointsWithAttributes(AttributeMatcherSet... att
269269
.collect(
270270
Collectors.toMap(KeyValue::getKey, kv -> kv.getValue().getStringValue()));
271271
int matchCount = 0;
272-
for (int i = 0; i < attributeMatchers.length; i++) {
273-
if (attributeMatchers[i].matches(dataPointAttributes)) {
272+
for (int i = 0; i < matcherGroups.length; i++) {
273+
if (matcherGroups[i].matches(dataPointAttributes)) {
274274
matchedSets[i] = true;
275275
matchCount++;
276276
}
277277
}
278278

279279
info.description(
280280
"data point attributes '%s' for metric '%s' must match exactly one of the attribute sets '%s'",
281-
dataPointAttributes, actual.getName(), Arrays.asList(attributeMatchers));
281+
dataPointAttributes, actual.getName(), Arrays.asList(matcherGroups));
282282
integers.assertEqual(info, matchCount, 1);
283283
}
284284

285285
// check that all attribute sets matched at least once
286286
for (int i = 0; i < matchedSets.length; i++) {
287287
info.description(
288288
"no data point matched attribute set '%s' for metric '%s'",
289-
attributeMatchers[i], actual.getName());
289+
matcherGroups[i], actual.getName());
290290
objects.assertEqual(info, matchedSets[i], true);
291291
}
292292
});

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/ActiveMqIntegrationTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package io.opentelemetry.contrib.jmxscraper.target_systems;
77

88
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attribute;
9-
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeSet;
9+
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeGroup;
1010

1111
import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
1212
import java.nio.file.Path;
@@ -48,7 +48,7 @@ protected MetricsVerifier createMetricsVerifier() {
4848
.hasUnit("{consumer}")
4949
.isUpDownCounter()
5050
.hasDataPointsWithAttributes(
51-
attributeSet(
51+
attributeGroup(
5252
attribute("destination", "ActiveMQ.Advisory.MasterBroker"),
5353
attribute("broker", "localhost"))))
5454
.add(
@@ -59,7 +59,7 @@ protected MetricsVerifier createMetricsVerifier() {
5959
.hasUnit("{producer}")
6060
.isUpDownCounter()
6161
.hasDataPointsWithAttributes(
62-
attributeSet(
62+
attributeGroup(
6363
attribute("destination", "ActiveMQ.Advisory.MasterBroker"),
6464
attribute("broker", "localhost"))))
6565
.add(
@@ -78,7 +78,7 @@ protected MetricsVerifier createMetricsVerifier() {
7878
.hasUnit("%")
7979
.isGauge()
8080
.hasDataPointsWithAttributes(
81-
attributeSet(
81+
attributeGroup(
8282
attribute("destination", "ActiveMQ.Advisory.MasterBroker"),
8383
attribute("broker", "localhost"))))
8484
.add(
@@ -107,7 +107,7 @@ protected MetricsVerifier createMetricsVerifier() {
107107
.hasUnit("{message}")
108108
.isUpDownCounter()
109109
.hasDataPointsWithAttributes(
110-
attributeSet(
110+
attributeGroup(
111111
attribute("destination", "ActiveMQ.Advisory.MasterBroker"),
112112
attribute("broker", "localhost"))))
113113
.add(
@@ -119,7 +119,7 @@ protected MetricsVerifier createMetricsVerifier() {
119119
.hasUnit("{message}")
120120
.isCounter()
121121
.hasDataPointsWithAttributes(
122-
attributeSet(
122+
attributeGroup(
123123
attribute("destination", "ActiveMQ.Advisory.MasterBroker"),
124124
attribute("broker", "localhost"))))
125125
.add(
@@ -130,7 +130,7 @@ protected MetricsVerifier createMetricsVerifier() {
130130
.hasUnit("{message}")
131131
.isCounter()
132132
.hasDataPointsWithAttributes(
133-
attributeSet(
133+
attributeGroup(
134134
attribute("destination", "ActiveMQ.Advisory.MasterBroker"),
135135
attribute("broker", "localhost"))))
136136
.add(
@@ -141,7 +141,7 @@ protected MetricsVerifier createMetricsVerifier() {
141141
.hasUnit("{message}")
142142
.isCounter()
143143
.hasDataPointsWithAttributes(
144-
attributeSet(
144+
attributeGroup(
145145
attribute("destination", "ActiveMQ.Advisory.MasterBroker"),
146146
attribute("broker", "localhost"))))
147147
.add(
@@ -152,7 +152,7 @@ protected MetricsVerifier createMetricsVerifier() {
152152
.hasUnit("ms")
153153
.isGauge()
154154
.hasDataPointsWithAttributes(
155-
attributeSet(
155+
attributeGroup(
156156
attribute("destination", "ActiveMQ.Advisory.MasterBroker"),
157157
attribute("broker", "localhost"))));
158158
}

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/CassandraIntegrationTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
package io.opentelemetry.contrib.jmxscraper.target_systems;
77

88
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attribute;
9-
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeSet;
9+
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeGroup;
1010

1111
import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
12-
import io.opentelemetry.contrib.jmxscraper.assertions.AttributeMatcherSet;
12+
import io.opentelemetry.contrib.jmxscraper.assertions.AttributeMatcherGroup;
1313
import java.nio.file.Path;
1414
import java.time.Duration;
1515
import org.testcontainers.containers.GenericContainer;
@@ -161,9 +161,9 @@ protected MetricsVerifier createMetricsVerifier() {
161161
.hasUnit("1")
162162
.isCounter()
163163
.hasDataPointsWithAttributes(
164-
attributeSet(attribute("operation", "RangeSlice")),
165-
attributeSet(attribute("operation", "Read")),
166-
attributeSet(attribute("operation", "Write"))))
164+
attributeGroup(attribute("operation", "RangeSlice")),
165+
attributeGroup(attribute("operation", "Read")),
166+
attributeGroup(attribute("operation", "Write"))))
167167
.add(
168168
"cassandra.client.request.error.count",
169169
metric ->
@@ -183,7 +183,7 @@ protected MetricsVerifier createMetricsVerifier() {
183183
errorCountAttributes("Write", "Unavailable")));
184184
}
185185

186-
private static AttributeMatcherSet errorCountAttributes(String operation, String status) {
187-
return attributeSet(attribute("operation", operation), attribute("status", status));
186+
private static AttributeMatcherGroup errorCountAttributes(String operation, String status) {
187+
return attributeGroup(attribute("operation", operation), attribute("status", status));
188188
}
189189
}

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/HBaseIntegrationTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package io.opentelemetry.contrib.jmxscraper.target_systems;
77

88
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attribute;
9-
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeSet;
9+
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeGroup;
1010
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeWithAnyValue;
1111

1212
import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
@@ -44,8 +44,8 @@ protected MetricsVerifier createMetricsVerifier() {
4444
.hasDescription("The number of region servers.")
4545
.hasUnit("{server}")
4646
.hasDataPointsWithAttributes(
47-
attributeSet(attribute("state", "dead")),
48-
attributeSet(attribute("state", "live"))))
47+
attributeGroup(attribute("state", "dead")),
48+
attributeGroup(attribute("state", "live"))))
4949
.add(
5050
"hbase.master.regions_in_transition.count",
5151
metric ->
@@ -128,9 +128,9 @@ protected MetricsVerifier createMetricsVerifier() {
128128
.hasDescription("The number of requests received.")
129129
.hasUnit("{request}")
130130
.hasDataPointsWithAttributes(
131-
attributeSet(
131+
attributeGroup(
132132
attribute("state", "write"), attributeWithAnyValue("region_server")),
133-
attributeSet(
133+
attributeGroup(
134134
attribute("state", "read"), attributeWithAnyValue("region_server"))))
135135
.add(
136136
"hbase.region_server.queue.length",
@@ -140,9 +140,9 @@ protected MetricsVerifier createMetricsVerifier() {
140140
.hasDescription("The number of RPC handlers actively servicing requests.")
141141
.hasUnit("{handler}")
142142
.hasDataPointsWithAttributes(
143-
attributeSet(
143+
attributeGroup(
144144
attribute("state", "flush"), attributeWithAnyValue("region_server")),
145-
attributeSet(
145+
attributeGroup(
146146
attribute("state", "compaction"),
147147
attributeWithAnyValue("region_server"))))
148148
.add(
@@ -162,9 +162,9 @@ protected MetricsVerifier createMetricsVerifier() {
162162
.hasDescription("Number of block cache hits/misses.")
163163
.hasUnit("{operation}")
164164
.hasDataPointsWithAttributes(
165-
attributeSet(
165+
attributeGroup(
166166
attribute("state", "miss"), attributeWithAnyValue("region_server")),
167-
attributeSet(
167+
attributeGroup(
168168
attribute("state", "hit"), attributeWithAnyValue("region_server"))))
169169
.add(
170170
"hbase.region_server.files.local",
@@ -436,17 +436,17 @@ protected MetricsVerifier createMetricsVerifier() {
436436
.hasDescription("Number of operations that took over 1000ms to complete.")
437437
.hasUnit("{operation}")
438438
.hasDataPointsWithAttributes(
439-
attributeSet(
439+
attributeGroup(
440440
attribute("operation", "delete"),
441441
attributeWithAnyValue("region_server")),
442-
attributeSet(
442+
attributeGroup(
443443
attribute("operation", "append"),
444444
attributeWithAnyValue("region_server")),
445-
attributeSet(
445+
attributeGroup(
446446
attribute("operation", "get"), attributeWithAnyValue("region_server")),
447-
attributeSet(
447+
attributeGroup(
448448
attribute("operation", "put"), attributeWithAnyValue("region_server")),
449-
attributeSet(
449+
attributeGroup(
450450
attribute("operation", "increment"),
451451
attributeWithAnyValue("region_server"))))
452452
.add(
@@ -473,12 +473,12 @@ protected MetricsVerifier createMetricsVerifier() {
473473
.hasDescription("The number of currently enqueued requests.")
474474
.hasUnit("{request}")
475475
.hasDataPointsWithAttributes(
476-
attributeSet(
476+
attributeGroup(
477477
attribute("state", "replication"),
478478
attributeWithAnyValue("region_server")),
479-
attributeSet(
479+
attributeGroup(
480480
attribute("state", "user"), attributeWithAnyValue("region_server")),
481-
attributeSet(
481+
attributeGroup(
482482
attribute("state", "priority"),
483483
attributeWithAnyValue("region_server"))))
484484
.add(
@@ -490,10 +490,10 @@ protected MetricsVerifier createMetricsVerifier() {
490490
"Number of client connection authentication failures/successes.")
491491
.hasUnit("{authentication request}")
492492
.hasDataPointsWithAttributes(
493-
attributeSet(
493+
attributeGroup(
494494
attribute("state", "successes"),
495495
attributeWithAnyValue("region_server")),
496-
attributeSet(
496+
attributeGroup(
497497
attribute("state", "failures"),
498498
attributeWithAnyValue("region_server"))))
499499
.add(

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/JettyIntegrationTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package io.opentelemetry.contrib.jmxscraper.target_systems;
77

88
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attribute;
9-
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeSet;
9+
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeGroup;
1010
import static io.opentelemetry.contrib.jmxscraper.assertions.DataPointAttributes.attributeWithAnyValue;
1111

1212
import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
@@ -88,7 +88,7 @@ protected MetricsVerifier createMetricsVerifier() {
8888
.hasDescription("The number of select calls.")
8989
.hasUnit("{operation}")
9090
.hasDataPointsWithAttributes(
91-
attributeSet(
91+
attributeGroup(
9292
attributeWithAnyValue("context"), attributeWithAnyValue("id"))))
9393
.add(
9494
"jetty.thread.count",
@@ -98,8 +98,8 @@ protected MetricsVerifier createMetricsVerifier() {
9898
.hasDescription("The current number of threads.")
9999
.hasUnit("{thread}")
100100
.hasDataPointsWithAttributes(
101-
attributeSet(attribute("state", "busy")),
102-
attributeSet(attribute("state", "idle"))))
101+
attributeGroup(attribute("state", "busy")),
102+
attributeGroup(attribute("state", "idle"))))
103103
.add(
104104
"jetty.thread.queue.count",
105105
metric ->

0 commit comments

Comments
 (0)