Skip to content

Commit 39a68b0

Browse files
align wildfly metrics with semconv (#14208)
Co-authored-by: otelbot <[email protected]>
1 parent 8d84677 commit 39a68b0

File tree

19 files changed

+508
-143
lines changed

19 files changed

+508
-143
lines changed

instrumentation/jmx-metrics/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ No targets are enabled by default. The supported target environments are listed
3030
- [jetty](library/jetty.md)
3131
- [kafka-broker](javaagent/kafka-broker.md)
3232
- [tomcat](library/tomcat.md)
33-
- [wildfly](javaagent/wildfly.md)
33+
- [wildfly](library/wildfly.md)
3434
- [hadoop](javaagent/hadoop.md)
3535

3636
The [jvm](library/jvm.md) metrics definitions are also included in the [jmx-metrics library](./library)

instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/wildfly.yaml

Lines changed: 0 additions & 83 deletions
This file was deleted.

instrumentation/jmx-metrics/javaagent/src/test/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstallerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class JmxMetricInsightInstallerTest {
3232
private static final String PATH_TO_ALL_EXISTING_RULES = "src/main/resources/jmx/rules";
3333
private static final Set<String> FILES_TO_BE_TESTED =
3434
new HashSet<>(
35-
Arrays.asList(
36-
"activemq.yaml", "camel.yaml", "hadoop.yaml", "kafka-broker.yaml", "wildfly.yaml"));
35+
Arrays.asList("activemq.yaml", "camel.yaml", "hadoop.yaml", "kafka-broker.yaml"));
3736

3837
@Test
3938
void testToVerifyExistingRulesAreValid() throws Exception {

instrumentation/jmx-metrics/javaagent/wildfly.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

instrumentation/jmx-metrics/library/build.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@ tasks {
2121
test {
2222
// get packaged agent jar for testing
2323
val shadowTask = project(":javaagent").tasks.named<ShadowJar>("shadowJar").get()
24-
2524
dependsOn(shadowTask)
2625

26+
val testAppTask = project(":instrumentation:jmx-metrics:testing-webapp").tasks.named<War>("war")
27+
dependsOn(testAppTask)
28+
2729
inputs.files(layout.files(shadowTask))
2830
.withPropertyName("javaagent")
2931
.withNormalizer(ClasspathNormalizer::class)
3032

3133
doFirst {
32-
jvmArgs("-Dio.opentelemetry.javaagent.path=${shadowTask.archiveFile.get()}")
34+
jvmArgs(
35+
"-Dio.opentelemetry.javaagent.path=${shadowTask.archiveFile.get()}",
36+
"-Dio.opentelemetry.testapp.path=${testAppTask.get().archiveFile.get().asFile.absolutePath}"
37+
)
3338
}
3439
}
3540
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
---
2+
rules:
3+
4+
- bean: jboss.as:deployment=*,subsystem=undertow
5+
prefix: wildfly.session.
6+
metricAttribute:
7+
wildfly.deployment: param(deployment)
8+
unit: "{session}"
9+
mapping:
10+
# wildfly.session.created
11+
sessionsCreated:
12+
metric: created
13+
type: counter
14+
desc: The number of sessions created
15+
# wildfly.session.active.count
16+
activeSessions:
17+
metric: active.count
18+
type: updowncounter
19+
desc: The number of active sessions
20+
# wildfly.session.active.limit
21+
maxActiveSessions:
22+
metric: active.limit
23+
type: updowncounter
24+
desc: The maximum number of active sessions
25+
# discard negative values used to indicate absence of limit
26+
dropNegativeValues: true
27+
# wildfly.session.expired
28+
expiredSessions:
29+
metric: expired
30+
type: counter
31+
desc: The number of expired sessions
32+
# wildfly.session.rejected
33+
rejectedSessions:
34+
metric: rejected
35+
type: counter
36+
desc: The number of rejected sessions
37+
38+
- bean: jboss.as:subsystem=undertow,server=*,http-listener=*
39+
prefix: wildfly.
40+
metricAttribute:
41+
wildfly.server: param(server)
42+
wildfly.listener: param(http-listener)
43+
type: counter
44+
mapping:
45+
# wildfly.request.count
46+
requestCount:
47+
metric: request.count
48+
unit: "{request}"
49+
desc: The number of requests served
50+
# wildfly.request.duration.sum
51+
processingTime:
52+
metric: request.duration.sum
53+
sourceUnit: ns
54+
unit: s
55+
desc: The total amount of time spent processing requests
56+
# wildfly.error.count
57+
errorCount:
58+
metric: error.count
59+
unit: "{request}"
60+
desc: The number of requests that have resulted in a 5xx response
61+
62+
# wildly.network.io
63+
- bean: jboss.as:subsystem=undertow,server=*,http-listener=*
64+
metricAttribute:
65+
wildfly.server: param(server)
66+
wildfly.listener: param(http-listener)
67+
type: counter
68+
unit: By
69+
mapping:
70+
bytesSent:
71+
metric: &metric wildfly.network.io
72+
desc: &desc Total number of bytes transferred
73+
metricAttribute:
74+
network.io.direction: const(transmit)
75+
bytesReceived:
76+
metric: *metric
77+
desc: *desc
78+
metricAttribute:
79+
network.io.direction: const(receive)
80+
81+
- bean: jboss.as:subsystem=datasources,data-source=*,statistics=pool
82+
prefix: wildfly.db.client.connection.
83+
metricAttribute:
84+
db.client.connection.pool.name: param(data-source)
85+
mapping:
86+
# wildfly.db.client.connection.count
87+
ActiveCount:
88+
metric: &metric count
89+
type: &type updowncounter
90+
unit: &unit "{connection}"
91+
desc: &desc The number of open physical database connections
92+
metricAttribute:
93+
db.client.connection.state: const(used)
94+
IdleCount:
95+
metric: *metric
96+
type: *type
97+
unit: *unit
98+
desc: *desc
99+
metricAttribute:
100+
db.client.connection.state: const(idle)
101+
# wildfly.db.client.connection.wait.count
102+
WaitCount:
103+
metric: wait.count
104+
type: counter
105+
# In this context, 'request' means 'connection request'
106+
unit: "{request}"
107+
desc: The number of connection requests that had to wait to obtain it
108+
109+
- bean: jboss.as:subsystem=transactions
110+
prefix: wildfly.transaction.
111+
unit: "{transaction}"
112+
mapping:
113+
# wildfly.transaction.count
114+
numberOfInflightTransactions:
115+
metric: count
116+
type: updowncounter
117+
desc: The number of in-flight transactions
118+
# wildfly.transaction.created
119+
numberOfTransactions:
120+
metric: created
121+
type: counter
122+
desc: The total number of transactions created
123+
# wildfly.transaction.committed
124+
numberOfCommittedTransactions:
125+
metric: committed
126+
type: counter
127+
desc: The total number of transactions committed
128+
# wildfly.transaction.rollback
129+
numberOfApplicationRollbacks:
130+
metric: &metric rollback
131+
type: &type counter
132+
metricAttribute:
133+
wildfly.rollback.cause: const(application)
134+
desc: &desc The total number of transactions rolled back
135+
numberOfResourceRollbacks:
136+
metric: *metric
137+
type: *type
138+
metricAttribute:
139+
wildfly.rollback.cause: const(resource)
140+
desc: *desc
141+
numberOfSystemRollbacks:
142+
metric: *metric
143+
type: *type
144+
metricAttribute:
145+
wildfly.rollback.cause: const(system)
146+
desc: *desc
147+
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
import org.junit.jupiter.params.provider.ValueSource;
2020
import org.testcontainers.containers.GenericContainer;
2121
import org.testcontainers.containers.wait.strategy.Wait;
22-
import org.testcontainers.images.builder.ImageFromDockerfile;
2322

24-
public class JettyIntegrationTest extends TargetSystemTest {
23+
public class JettyTest extends TargetSystemTest {
2524

2625
private static final int JETTY_PORT = 8080;
2726

@@ -48,25 +47,20 @@ void testCollectedMetrics(int jettyMajorVersion) {
4847
// with older versions deployment and session management are available by default
4948
jettyModules.add("stats");
5049
}
51-
String addModulesArg = "--add-to-startd=" + String.join(",", jettyModules);
50+
String moduleArg = "--module=" + String.join(",", jettyModules);
5251

5352
GenericContainer<?> container =
54-
new GenericContainer<>(
55-
new ImageFromDockerfile()
56-
.withDockerfileFromBuilder(
57-
builder ->
58-
builder
59-
.from("jetty:" + jettyMajorVersion)
60-
.run("java", "-jar", "/usr/local/jetty/start.jar", addModulesArg)
61-
.run("mkdir -p /var/lib/jetty/webapps/ROOT/")
62-
.run("touch /var/lib/jetty/webapps/ROOT/index.html")
63-
.build()))
53+
new GenericContainer<>("jetty:" + jettyMajorVersion)
54+
.withCommand(moduleArg)
6455
.withEnv("JAVA_OPTIONS", String.join(" ", jvmArgs))
6556
.withStartupTimeout(Duration.ofMinutes(2))
6657
.withExposedPorts(JETTY_PORT)
6758
.waitingFor(Wait.forListeningPorts(JETTY_PORT));
6859

69-
copyFilesToTarget(container, yamlFiles);
60+
copyAgentToTarget(container);
61+
copyYamlFilesToTarget(container, yamlFiles);
62+
// Deploy example web application for session-related metrics
63+
copyTestWebAppToTarget(container, "/var/lib/jetty/webapps/ROOT.war");
7064

7165
startTarget(container);
7266

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.testcontainers.containers.GenericContainer;
2121
import org.testcontainers.containers.wait.strategy.Wait;
2222

23-
class JvmTargetSystemTest extends TargetSystemTest {
23+
class JvmTest extends TargetSystemTest {
2424

2525
@ParameterizedTest
2626
@ValueSource(
@@ -47,7 +47,8 @@ void testJvmMetrics(String image) {
4747
.withExposedPorts(8080)
4848
.waitingFor(Wait.forListeningPorts(8080));
4949

50-
copyFilesToTarget(target, yamlFiles);
50+
copyAgentToTarget(target);
51+
copyYamlFilesToTarget(target, yamlFiles);
5152

5253
startTarget(target);
5354

0 commit comments

Comments
 (0)