Skip to content

Commit a8a5b63

Browse files
committed
Code review followup
1 parent fb5d0c7 commit a8a5b63

File tree

4 files changed

+40
-33
lines changed

4 files changed

+40
-33
lines changed

instrumentation/jmx-metrics/library/hadoop.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
Here is the list of metrics based on MBeans exposed by Hadoop.
44

5-
| Metric Name | Type | Attributes | Description |
6-
|---------------------------------|---------------|-------------------------------------|--------------------------------------------------------|
7-
| hadoop.dfs.capacity | UpDownCounter | hadoop.node.name | Current raw capacity of data nodes. |
8-
| hadoop.dfs.capacity.used | UpDownCounter | hadoop.node.name | Current used capacity across all data nodes. |
9-
| hadoop.dfs.block.count | UpDownCounter | hadoop.node.name | Current number of allocated blocks in the system. |
10-
| hadoop.dfs.block.missing | UpDownCounter | hadoop.node.name | Current number of missing blocks. |
11-
| hadoop.dfs.block.corrupt | UpDownCounter | hadoop.node.name | Current number of blocks with corrupt replicas. |
12-
| hadoop.dfs.volume.failure.count | Counter | hadoop.node.name | Total number of volume failures across all data nodes. |
13-
| hadoop.dfs.file.count | UpDownCounter | hadoop.node.name | Current number of files and directories. |
14-
| hadoop.dfs.connection.count | UpDownCounter | hadoop.node.name | Current number of connection. |
15-
| hadoop.dfs.data_node.count | UpDownCounter | hadoop.node.name, hadoop.node.state | The number of data nodes. |
5+
| Metric Name | Type | Unit | Attributes | Description |
6+
|---------------------------------|---------------|--------------|-------------------|--------------------------------------------------------|
7+
| hadoop.dfs.capacity | UpDownCounter | By | hadoop.node.name | Current raw capacity of data nodes. |
8+
| hadoop.dfs.capacity.used | UpDownCounter | By | hadoop.node.name | Current used capacity across all data nodes. |
9+
| hadoop.dfs.block.count | UpDownCounter | {block} | hadoop.node.name | Current number of allocated blocks in the system. |
10+
| hadoop.dfs.block.missing | UpDownCounter | {block} | hadoop.node.name | Current number of missing blocks. |
11+
| hadoop.dfs.block.corrupt | UpDownCounter | {block} | hadoop.node.name | Current number of blocks with corrupt replicas. |
12+
| hadoop.dfs.volume.failure.count | Counter | {failure} | hadoop.node.name | Total number of volume failures across all data nodes. |
13+
| hadoop.dfs.file.count | UpDownCounter | {file} | hadoop.node.name | Current number of files and directories. |
14+
| hadoop.dfs.connection.count | UpDownCounter | {connection} | hadoop.node.name | Current number of connection. |
15+
| hadoop.dfs.data_node.live | UpDownCounter | {node} | hadoop.node.name | Number of data nodes which are currently live. |
16+
| hadoop.dfs.data_node.dead | UpDownCounter | {node} | hadoop.node.name | Number of data nodes which are currently dead. |

instrumentation/jmx-metrics/library/src/main/resources/jmx/rules/hadoop.yaml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,15 @@ rules:
5454
unit: "{connection}"
5555
desc: Current number of connections.
5656

57-
# hadoop.dfs.data_node.count
57+
# hadoop.dfs.data_node.live
5858
NumLiveDataNodes:
59-
metric: &metric data_node.count
60-
type: &type updowncounter
61-
unit: &unit "{node}"
62-
desc: &desc The number of DataNodes.
63-
metricAttribute:
64-
hadoop.node.state: const(live)
59+
metric: data_node.live
60+
type: updowncounter
61+
unit: "{node}"
62+
desc: Number of data nodes which are currently live.
63+
# hadoop.dfs.data_node.dead
6564
NumDeadDataNodes:
66-
metric: *metric
67-
type: *type
68-
unit: *unit
69-
desc: *desc
70-
metricAttribute:
71-
hadoop.node.state: const(dead)
65+
metric: data_node.dead
66+
type: updowncounter
67+
unit: "{node}"
68+
desc: Number of data nodes which are currently dead.

instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/HadoopTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.opentelemetry.instrumentation.jmx.rules;
77

88
import static io.opentelemetry.instrumentation.jmx.rules.assertions.DataPointAttributes.attribute;
9-
import static io.opentelemetry.instrumentation.jmx.rules.assertions.DataPointAttributes.attributeGroup;
109

1110
import io.opentelemetry.instrumentation.jmx.rules.assertions.AttributeMatcher;
1211
import java.io.IOException;
@@ -61,7 +60,7 @@ private String readAndPreprocessEnvFile(String fileName) throws URISyntaxExcepti
6160
try (Stream<String> lines = Files.lines(path)) {
6261
data =
6362
lines
64-
.map(line -> line.replace(ENDPOINT_PLACEHOLDER, otlpEndpoint))
63+
.map(line -> line.replace(ENDPOINT_PLACEHOLDER, getOtlpEndpoint()))
6564
.collect(Collectors.joining("\n"));
6665
}
6766

@@ -164,14 +163,20 @@ private static MetricsVerifier createMetricsVerifier() {
164163
.isUpDownCounter()
165164
.hasDataPointsWithOneAttribute(nodeNameAttribute))
166165
.add(
167-
"hadoop.dfs.data_node.count",
166+
"hadoop.dfs.data_node.live",
168167
metric ->
169168
metric
170-
.hasDescription("The number of DataNodes.")
169+
.hasDescription("Number of data nodes which are currently live.")
171170
.hasUnit("{node}")
172171
.isUpDownCounter()
173-
.hasDataPointsWithAttributes(
174-
attributeGroup(attribute("hadoop.node.state", "live"), nodeNameAttribute),
175-
attributeGroup(attribute("hadoop.node.state", "dead"), nodeNameAttribute)));
172+
.hasDataPointsWithOneAttribute(nodeNameAttribute))
173+
.add(
174+
"hadoop.dfs.data_node.dead",
175+
metric ->
176+
metric
177+
.hasDescription("Number of data nodes which are currently dead.")
178+
.hasUnit("{node}")
179+
.isUpDownCounter()
180+
.hasDataPointsWithOneAttribute(nodeNameAttribute));
176181
}
177182
}

instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/TargetSystemTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public class TargetSystemTest {
6363
private static OtlpGrpcServer otlpServer;
6464
private static Path agentPath;
6565
private static Path testAppPath;
66-
protected static String otlpEndpoint;
66+
67+
private static String otlpEndpoint;
6768

6869
private GenericContainer<?> targetSystem;
6970
private Collection<GenericContainer<?>> targetDependencies;
@@ -120,6 +121,10 @@ static void afterAll() {
120121
}
121122
}
122123

124+
protected static String getOtlpEndpoint() {
125+
return otlpEndpoint;
126+
}
127+
123128
protected static String javaAgentJvmArgument() {
124129
return "-javaagent:" + AGENT_PATH;
125130
}
@@ -150,7 +155,6 @@ protected static Map<String, String> otelConfigProperties(List<String> yamlFiles
150155
// disable runtime telemetry metrics
151156
config.put("otel.instrumentation.runtime-telemetry.enabled", "false");
152157
// set yaml config files to test
153-
config.put("otel.jmx.target", "hadoop");
154158
config.put(
155159
"otel.jmx.config",
156160
yamlFiles.stream()

0 commit comments

Comments
 (0)