Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/modules/ROOT/pages/reference/jvm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ another. The reported value underestimates the actual total number of steals whe
* `executor.parallelism` (`Gauge`): The targeted parallelism level of this pool.
* `executor.pool.size` (`Gauge`): The current number of threads in the pool.

To use the following `ExecutorService` instances, `--add-opens java.base/java.util.concurrent=ALL-UNNAMED` is required:

* `Executors.newSingleThreadScheduledExecutor()`
* `Executors.newSingleThreadExecutor()`
* `Executors.newThreadPerTaskExecutor()`
* `Executors.newVirtualThreadPerTaskExecutor()`

== Java 21 Metrics

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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
* {@link ExecutorService}, like {@link TimedExecutorService}. Make sure to pass the
* underlying, unwrapped ExecutorService to this MeterBinder, if it is wrapped in another
* type.
* <p>
* To use the following {@link ExecutorService} instances,
* {@literal --add-opens java.base/java.util.concurrent=ALL-UNNAMED} is required:
* <ul>
* <li>Executors.newSingleThreadScheduledExecutor()</li>
* <li>Executors.newSingleThreadExecutor()</li>
* <li>Executors.newThreadPerTaskExecutor()</li>
* <li>Executors.newVirtualThreadPerTaskExecutor()</li>
* </ul>
*
* @author Jon Schneider
* @author Clint Checketts
Expand Down Expand Up @@ -315,14 +324,18 @@ else if (executorService instanceof ForkJoinPool) {
monitor(registry, (ForkJoinPool) executorService);
}
else if (allowIllegalReflectiveAccess) {
// For Executors.newSingleThreadScheduledExecutor()
if (className.equals("java.util.concurrent.Executors$DelegatedScheduledExecutorService")) {
monitor(registry, unwrapThreadPoolExecutor(executorService, executorService.getClass()));
}
// For Executors.newSingleThreadExecutor()
else if (className.equals("java.util.concurrent.Executors$FinalizableDelegatedExecutorService")
|| className.equals("java.util.concurrent.Executors$AutoShutdownDelegatedExecutorService")) {
monitor(registry,
unwrapThreadPoolExecutor(executorService, executorService.getClass().getSuperclass()));
}
// For Executors.newThreadPerTaskExecutor() and
// Executors.newVirtualThreadPerTaskExecutor()
else if (className.equals(CLASS_NAME_THREAD_PER_TASK_EXECUTOR)) {
monitorThreadPerTaskExecutor(registry, executorService);
}
Expand Down