Skip to content

Commit db42889

Browse files
committed
Code review changes
1 parent 002d6ab commit db42889

File tree

3 files changed

+54
-29
lines changed

3 files changed

+54
-29
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public class HBaseIntegrationTest extends TargetSystemIntegrationTest {
2323
@Override
2424
protected GenericContainer<?> createTargetContainer(int jmxPort) {
2525
return new GenericContainer<>("dajobe/hbase")
26-
.withEnv("JAVA_HOME", "/usr/lib/jvm/java-8-openjdk-amd64")
27-
.withEnv("HBASE_OPTS", "-XX:+UseConcMarkSweepGC")
2826
.withEnv("HBASE_MASTER_OPTS", genericJmxJvmArguments(jmxPort))
2927
.withStartupTimeout(Duration.ofMinutes(2))
3028
.withExposedPorts(jmxPort, DEFAULT_MASTER_SERVICE_PORT)

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static void assertGauge(Metric metric, String name, String description, String u
2727
assertThat(metric.getName()).isEqualTo(name);
2828
assertThat(metric.getDescription()).isEqualTo(description);
2929
assertThat(metric.getUnit()).isEqualTo(unit);
30-
assertThat(metric.hasGauge()).withFailMessage("Invalid metric type").isTrue();
30+
assertMetricWithGauge(metric);
3131
assertThat(metric.getGauge().getDataPointsList())
3232
.satisfiesExactly(point -> assertThat(point.getAttributesList()).isEmpty());
3333
}
@@ -41,10 +41,7 @@ static void assertSum(
4141
assertThat(metric.getName()).isEqualTo(name);
4242
assertThat(metric.getDescription()).isEqualTo(description);
4343
assertThat(metric.getUnit()).isEqualTo(unit);
44-
assertThat(metric.hasSum()).withFailMessage("Invalid metric type").isTrue();
45-
assertThat(metric.getSum().getIsMonotonic())
46-
.withFailMessage("Metric should " + (isMonotonic ? "" : "not ") + "be monotonic")
47-
.isEqualTo(isMonotonic);
44+
assertMetricWithSum(metric, isMonotonic);
4845
assertThat(metric.getSum().getDataPointsList())
4946
.satisfiesExactly(point -> assertThat(point.getAttributesList()).isEmpty());
5047
}
@@ -54,7 +51,7 @@ static void assertTypedGauge(
5451
assertThat(metric.getName()).isEqualTo(name);
5552
assertThat(metric.getDescription()).isEqualTo(description);
5653
assertThat(metric.getUnit()).isEqualTo(unit);
57-
assertThat(metric.hasGauge()).withFailMessage("Invalid metric type").isTrue();
54+
assertMetricWithGauge(metric);
5855
assertTypedPoints(metric.getGauge().getDataPointsList(), types);
5956
}
6057

@@ -63,7 +60,7 @@ static void assertTypedSum(
6360
assertThat(metric.getName()).isEqualTo(name);
6461
assertThat(metric.getDescription()).isEqualTo(description);
6562
assertThat(metric.getUnit()).isEqualTo(unit);
66-
assertThat(metric.hasSum()).withFailMessage("Invalid metric type").isTrue();
63+
assertMetricWithSum(metric);
6764
assertTypedPoints(metric.getSum().getDataPointsList(), types);
6865
}
6966

@@ -89,10 +86,7 @@ static void assertSumWithAttributes(
8986
assertThat(metric.getName()).isEqualTo(name);
9087
assertThat(metric.getDescription()).isEqualTo(description);
9188
assertThat(metric.getUnit()).isEqualTo(unit);
92-
assertThat(metric.hasSum()).withFailMessage("Invalid metric type").isTrue();
93-
assertThat(metric.getSum().getIsMonotonic())
94-
.withFailMessage("Metric should " + (isMonotonic ? "" : "not ") + "be monotonic")
95-
.isEqualTo(isMonotonic);
89+
assertMetricWithSum(metric, isMonotonic);
9690
assertAttributedPoints(metric.getSum().getDataPointsList(), attributeGroupAssertions);
9791
}
9892

@@ -107,8 +101,7 @@ static void assertSumWithAttributesMultiplePoints(
107101
assertThat(metric.getName()).isEqualTo(name);
108102
assertThat(metric.getDescription()).isEqualTo(description);
109103
assertThat(metric.getUnit()).isEqualTo(unit);
110-
assertThat(metric.hasSum()).isTrue();
111-
assertThat(metric.getSum().getIsMonotonic()).isEqualTo(isMonotonic);
104+
assertMetricWithSum(metric, isMonotonic);
112105
assertAttributedMultiplePoints(metric.getSum().getDataPointsList(), attributeGroupAssertions);
113106
}
114107

@@ -122,10 +115,25 @@ static void assertGaugeWithAttributes(
122115
assertThat(metric.getName()).isEqualTo(name);
123116
assertThat(metric.getDescription()).isEqualTo(description);
124117
assertThat(metric.getUnit()).isEqualTo(unit);
125-
assertThat(metric.hasGauge()).withFailMessage("Invalid metric type").isTrue();
118+
assertMetricWithGauge(metric);
126119
assertAttributedPoints(metric.getGauge().getDataPointsList(), attributeGroupAssertions);
127120
}
128121

122+
private static void assertMetricWithGauge(Metric metric) {
123+
assertThat(metric.hasGauge()).withFailMessage("Metric with gauge expected").isTrue();
124+
}
125+
126+
private static void assertMetricWithSum(Metric metric) {
127+
assertThat(metric.hasSum()).withFailMessage("Metric with sum expected").isTrue();
128+
}
129+
130+
private static void assertMetricWithSum(Metric metric, boolean isMonotonic) {
131+
assertMetricWithSum(metric);
132+
assertThat(metric.getSum().getIsMonotonic())
133+
.withFailMessage("Metric should " + (isMonotonic ? "" : "not ") + "be monotonic")
134+
.isEqualTo(isMonotonic);
135+
}
136+
129137
@SuppressWarnings("unchecked")
130138
private static void assertTypedPoints(List<NumberDataPoint> points, List<String> types) {
131139
Consumer<MapAssert<String, String>>[] assertions =

jmx-scraper/src/main/resources/hbase.yaml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ rules:
77
unit: "{server}"
88
type: updowncounter
99
mapping:
10+
# Group of properties to build hbase.master.region_server.count metric
1011
numDeadRegionServers:
1112
metric: &metric region_server.count
1213
desc: &desc The number of region servers.
@@ -26,9 +27,11 @@ rules:
2627
ritCount:
2728
metric: count
2829
desc: The number of regions that are in transition.
30+
2931
ritCountOverThreshold:
3032
metric: over_threshold
3133
desc: The number of regions that have been in transition longer than a threshold time.
34+
3235
ritOldestAge:
3336
metric: oldest_age
3437
unit: ms
@@ -61,6 +64,19 @@ rules:
6164
unit: "{log}"
6265
desc: The number of write ahead logs not yet archived.
6366

67+
percentFilesLocal:
68+
metric: files.local
69+
type: gauge
70+
unit: "%"
71+
desc: Percent of store file data that can be read from the local.
72+
73+
updatesBlockedTime:
74+
metric: blocked_update.time
75+
type: gauge
76+
unit: ms
77+
desc: Amount of time updates have been blocked so the memstore can be flushed.
78+
79+
# Group of properties to build hbase.region_server.request.count metric
6480
writeRequestCount:
6581
metric: &metric request.count
6682
unit: &unit "{request}"
@@ -76,6 +92,7 @@ rules:
7692
state: const(read)
7793
region_server: *hostname
7894

95+
# Group of properties to build hbase.region_server.queue.length metric
7996
flushQueueLength:
8097
metric: &metric queue.length
8198
unit: &unit "{handler}"
@@ -91,12 +108,7 @@ rules:
91108
state: const(compaction)
92109
region_server: *hostname
93110

94-
updatesBlockedTime:
95-
metric: blocked_update.time
96-
type: gauge
97-
unit: ms
98-
desc: Amount of time updates have been blocked so the memstore can be flushed.
99-
111+
# Group of properties to build hbase.region_server.block_cache.operation.count metric
100112
blockCacheMissCount:
101113
metric: &metric block_cache.operation.count
102114
type: &type gauge
@@ -114,19 +126,14 @@ rules:
114126
state: const(hit)
115127
region_server: *hostname
116128

117-
percentFilesLocal:
118-
metric: files.local
119-
type: gauge
120-
unit: "%"
121-
desc: Percent of store file data that can be read from the local.
122-
129+
# Group of properties to build hbase.region_server.operations.slow metric
123130
slowDeleteCount:
124131
metric: &metric operations.slow
125132
unit: &unit "{operation}"
126133
desc: &desc Number of operations that took over 1000ms to complete.
127134
metricAttribute:
128135
operation: const(delete)
129-
region_server: &hostname beanattr(tag\.Hostname)
136+
region_server: *hostname
130137
slowAppendCount:
131138
metric: *metric
132139
unit: *unit
@@ -156,13 +163,15 @@ rules:
156163
operation: const(increment)
157164
region_server: *hostname
158165

166+
# RegionServer statistical metrics
159167
- bean: Hadoop:service=HBase,name=RegionServer,sub=Server
160168
prefix: hbase.region_server.
161169
type: gauge
162170
unit: ms
163171
metricAttribute:
164172
region_server: *hostname
165173
mapping:
174+
# Statistics for 'append' operation
166175
Append_99th_percentile:
167176
metric: operation.append.latency.p99
168177
desc: Append operation 99th Percentile latency.
@@ -179,6 +188,7 @@ rules:
179188
metric: operation.append.latency.median
180189
desc: Append operation median latency.
181190

191+
# Statistics for 'delete' operation
182192
Delete_99th_percentile:
183193
metric: operation.delete.latency.p99
184194
desc: Delete operation 99th Percentile latency.
@@ -195,6 +205,7 @@ rules:
195205
metric: operation.delete.latency.median
196206
desc: Delete operation median latency.
197207

208+
# Statistics for 'put' operation
198209
Put_99th_percentile:
199210
metric: operation.put.latency.p99
200211
desc: Put operation 99th Percentile latency.
@@ -211,6 +222,7 @@ rules:
211222
metric: operation.put.latency.median
212223
desc: Put operation median latency.
213224

225+
# Statistics for 'get' operation
214226
Get_99th_percentile:
215227
metric: operation.get.latency.p99
216228
desc: Get operation 99th Percentile latency.
@@ -227,6 +239,7 @@ rules:
227239
metric: operation.get.latency.median
228240
desc: Get operation median latency.
229241

242+
# Statistics for 'replay' operation
230243
Replay_99th_percentile:
231244
metric: operation.replay.latency.p99
232245
desc: Replay operation 99th Percentile latency.
@@ -243,6 +256,7 @@ rules:
243256
metric: operation.replay.latency.median
244257
desc: Replay operation median latency.
245258

259+
# Statistics for 'increment' operation
246260
Increment_99th_percentile:
247261
metric: operation.increment.latency.p99
248262
desc: Increment operation 99th Percentile latency.
@@ -269,11 +283,13 @@ rules:
269283
metric: open_connection.count
270284
unit: "{connection}"
271285
desc: The number of open connections at the RPC layer.
286+
272287
numActiveHandler:
273288
metric: active_handler.count
274289
unit: "{handler}"
275290
desc: The number of RPC handlers actively servicing requests.
276291

292+
# Group of properties to build hbase.region_server.queue.request.count metric
277293
numCallsInReplicationQueue:
278294
metric: &metric queue.request.count
279295
unit: &unit "{request}"
@@ -296,6 +312,7 @@ rules:
296312
state: const(priority)
297313
region_server: *hostname
298314

315+
# Group of properties to build hbase.region_server.authentication.count metric
299316
authenticationSuccesses:
300317
metric: &metric authentication.count
301318
unit: &unit "{authentication request}"
@@ -321,9 +338,11 @@ rules:
321338
GcTimeMillis:
322339
metric: time
323340
desc: Time spent in garbage collection.
341+
324342
GcTimeMillisParNew:
325343
metric: young_gen.time
326344
desc: Time spent in garbage collection of the young generation.
345+
327346
GcTimeMillisConcurrentMarkSweep:
328347
metric: old_gen.time
329348
desc: Time spent in garbage collection of the old generation.

0 commit comments

Comments
 (0)