Skip to content

Commit 327b2e7

Browse files
committed
finish jetty 12 support + doc
1 parent a8793e3 commit 327b2e7

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

instrumentation/jmx-metrics/library/jetty.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The metrics captured and their respective attributes depend on the Jetty version
88

99
## Jetty 12 and later
1010

11-
Those metrics require the following Jetty modules to be enabled : `jmx`, `http` and `statistics`.
11+
Those metrics require the following Jetty modules to be enabled : `jmx`, `http`, `statistics`, `sessions` and at least one of `ee8-deploy`, `ee9-deploy` or `ee10-deploy`.
1212

1313
| Metric Name | Type | Attributes | Description |
1414
|-------------------------|---------------|--------------------------------------------|-------------------------------------------|
@@ -17,17 +17,37 @@ Those metrics require the following Jetty modules to be enabled : `jmx`, `http`
1717
| jetty.thread.busy.count | UpDownCounter | jetty.thread.pool.id, jetty.thread.context | The current number of busy threads |
1818
| jetty.thread.idle.count | UpDownCounter | jetty.thread.pool.id, jetty.thread.context | The current number of idle threads |
1919
| jetty.thread.queue.size | UpDownCounter | jetty.thread.pool.id, jetty.thread.context | The current job queue size |
20-
| jetty.io.select.count | Counter | jetty.selector.resource, jetty.selector.id | The number of select calls |
20+
| jetty.io.select.count | Counter | jetty.selector.context, jetty.selector.id | The number of select calls |
21+
| jetty.session.count | UpDownCounter | jetty.context, jetty.session.cache.id | Current number of active sessions |
22+
| jetty.session.count.max | Gauge | jetty.context, jetty.session.cache.id | Maximum number of active sessions |
23+
24+
- `jetty.context` corresponds to the deployed application subfolder in `webapps` folder.
25+
- `jetty.selector.context` is a technical string identifier, high cardinality with values like `HTTP_1_1@7674f035` but stable per Jetty process instance
26+
- `jetty.selector.id` is a technical numeric identifier, usually with low cardinality between `0` and `9`.
27+
- `jetty.session.cache.id` is a technical numeric identifier, usually single `0` value is used
28+
- `jetty.thread.context` is a technical string identifier, high cardinality with values like `Server@5a411614` but stable per Jetty process instance
29+
- `jetty.thread.pool.id` is a technical numeric identifier, usually single `0` value is used
2130

2231
## Jetty 9 to 11
2332

2433
Those metrics require the following Jetty modules to be enabled : `jmx`, `http` and `stats`.
2534

26-
| Metric Name | Type | Attributes | Description |
27-
|-------------------------|---------------|--------------------------------------------|-------------------------------------------|
28-
| jetty.thread.count | UpDownCounter | jetty.thread.pool.id | The current number of threads |
29-
| jetty.thread.limit | UpDownCounter | jetty.thread.pool.id | The maximum number of threads in the pool |
30-
| jetty.thread.busy.count | UpDownCounter | jetty.thread.pool.id | The current number of busy threads |
31-
| jetty.thread.idle.count | UpDownCounter | jetty.thread.pool.id | The current number of idle threads |
32-
| jetty.thread.queue.size | UpDownCounter | jetty.thread.pool.id | The current job queue size |
33-
| jetty.io.select.count | Counter | jetty.selector.resource, jetty.selector.id | The number of select calls |
35+
| Metric Name | Type | Attributes | Description |
36+
|-----------------------------|---------------|-------------------------------------------|-------------------------------------------|
37+
| jetty.thread.count | UpDownCounter | jetty.thread.pool.id | The current number of threads |
38+
| jetty.thread.limit | UpDownCounter | jetty.thread.pool.id | The maximum number of threads in the pool |
39+
| jetty.thread.busy.count | UpDownCounter | jetty.thread.pool.id | The current number of busy threads |
40+
| jetty.thread.idle.count | UpDownCounter | jetty.thread.pool.id | The current number of idle threads |
41+
| jetty.thread.queue.size | UpDownCounter | jetty.thread.pool.id | The current job queue size |
42+
| jetty.io.select.count | Counter | jetty.selector.context, jetty.selector.id | The number of select calls |
43+
| jetty.session.created.count | Counter | jetty.context, jetty.session.handler.id | The total number of created sessions |
44+
| jetty.session.duration.sum | Gauge | jetty.context, jetty.session.handler.id | The cumulated session duration |
45+
| jetty.session.duration.max | Gauge | jetty.context, jetty.session.handler.id | The maximum session duration |
46+
| jetty.session.duration.mean | Gauge | jetty.context, jetty.session.handler.id | The mean session duration |
47+
48+
- `jetty.context` corresponds to the deployed application subfolder in `webapps` folder.
49+
- `jetty.selector.context` is a technical string identifier, high cardinality with values like `HTTP_1_1@7674f035` but stable per Jetty process instance
50+
- `jetty.selector.id` is a technical numeric identifier, usually with low cardinality between `0` and `9`.
51+
- `jetty.session.cache.id` is a technical numeric identifier, usually single `0` value is used
52+
- `jetty.thread.pool.id` is a technical numeric identifier, usually single `0` value is used
53+
- `jetty.session.handler.id` is a technical numeric identifier, usually single `0` value is used

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ rules:
6666

6767
- bean: org.eclipse.jetty.io:context=*,type=managedselector,id=*
6868
metricAttribute:
69-
# 'id' is a numerical value in [0,9] by default
70-
jetty.selector.context: param(context)
7169
# 'context' is a high cardinality value like 'HTTP_1_1@7674f035' but likely stable for the
7270
# duration of the jetty process lifecycle
71+
jetty.selector.context: param(context)
72+
# 'id' is a numerical value in [0,9] by default
7373
jetty.selector.id: param(id)
7474
mapping:
7575
# jetty.select.count
@@ -81,7 +81,6 @@ rules:
8181

8282
# Session metrics for Jetty 12
8383
- bean: org.eclipse.jetty.session:context=*,type=defaultsessioncache,id=*
84-
# org.eclipse.jetty.session:context=ROOT,type=defaultsessioncache,id=0
8584
prefix: jetty.session.
8685
unit: "{session}"
8786
metricAttribute:

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ void testCollectedMetrics(int jettyMajorVersion) {
4141
Set<String> jettyModules = new HashSet<>(Arrays.asList("jmx", "http"));
4242
if (jettyMajorVersion >= 12) {
4343
jettyModules.add("statistics");
44+
// required for session management
45+
jettyModules.add("sessions");
46+
// required for deployment support in 'webapps' folder
47+
jettyModules.add("ee10-deploy");
4448
} else {
49+
// with older versions deployment and session management are available by default
4550
jettyModules.add("stats");
4651
}
4752
String addModulesArg = "--add-to-startd=" + String.join(",", jettyModules);
@@ -152,7 +157,7 @@ private static MetricsVerifier createMetricsVerifier(int jettyMajorVersion) {
152157
"jetty.session.count.max",
153158
metric ->
154159
metric
155-
.isUpDownCounter()
160+
.isGauge()
156161
.hasDescription("Maximum number of active sessions")
157162
.hasUnit("{session}")
158163
.hasDataPointsWithAttributes(

0 commit comments

Comments
 (0)