You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/reference/jvm.adoc
+33-2
Original file line number
Diff line number
Diff line change
@@ -54,11 +54,42 @@ To use the following `ExecutorService` instances, `--add-opens java.base/java.ut
54
54
55
55
== Java 21 Metrics
56
56
57
-
Micrometer provides support for https://openjdk.org/jeps/444[virtual threads] released in Java 21. In order to utilize it, you need to add the `io.micrometer:micrometer-java21` dependency to your classpath to use the binder:
57
+
=== Virtual Threads
58
+
59
+
Micrometer provides metrics for https://openjdk.org/jeps/444[virtual threads] released in Java 21. In order to utilize it, you need to add the `io.micrometer:micrometer-java21` dependency to your classpath to use the binder:
58
60
59
61
[source, java]
60
62
----
61
63
new VirtualThreadMetrics().bindTo(registry);
62
64
----
63
65
64
-
The binder measures the duration (and counts the number of events) of virtual threads being pinned; also counts the number of events when starting or unparking a virtual thread failed.
66
+
The binder measures the duration (and counts the number of events) of virtual threads being pinned; it also counts the number of events when starting or unparking a virtual thread failed.
67
+
68
+
If you are running your application with Java 24 or later on a JVM that has `jdk.management.VirtualThreadSchedulerMXBean` provided as a platform MXBean, the following additional virtual thread metrics will be provided.
69
+
70
+
71
+
|===
72
+
|Meter name | Type | Tag(s) | Description
73
+
74
+
|`jvm.threads.virtual.parallelism`
75
+
|Gauge
76
+
|
77
+
|Virtual thread scheduler's target parallelism
78
+
79
+
|`jvm.threads.virtual.pool.size`
80
+
|Gauge
81
+
|
82
+
|Current number of platform threads that the scheduler has started but have not terminated; -1 if not known.
83
+
84
+
|`jvm.threads.virtual.live`
85
+
|Gauge
86
+
|`scheduling.status` = `mounted`
87
+
|Approximate current number of virtual threads that are unfinished and mounted to a platform thread by the scheduler
88
+
89
+
|`jvm.threads.virtual.live`
90
+
|Gauge
91
+
|`scheduling.status` = `queued`
92
+
|Approximate current number of virtual threads that are unfinished and queued waiting to be scheduled
93
+
|===
94
+
95
+
Note that aggregating the values of `jvm.threads.virtual.live` across the different tags gives the total number of virtual threads started but not ended.
0 commit comments