Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring boot runtime metrics #13078

Closed
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
disable threads
  • Loading branch information
zeitlinger committed Jan 30, 2025
commit b15e5cb84a7e888cd29b7b876db7ac8329f678ec
Original file line number Diff line number Diff line change
@@ -60,12 +60,6 @@ public static List<AutoCloseable> registerObservers(OpenTelemetry openTelemetry)
return INSTANCE.registerObservers(openTelemetry, useThreads());
}

private static boolean useThreads() {
// GraalVM native image does not support ThreadMXBean yet
// see https://github.com/oracle/graal/issues/6101
return !isJava9OrNewer() || System.getProperty("org.graalvm.nativeimage.imagecode") != null;
}

private List<AutoCloseable> registerObservers(OpenTelemetry openTelemetry, boolean useThread) {
if (useThread) {
return registerObservers(openTelemetry, Threads::getThreads);
@@ -122,6 +116,12 @@ private static boolean isJava9OrNewer() {
return THREAD_INFO_IS_DAEMON != null;
}

private static boolean useThreads() {
// GraalVM native image does not support ThreadMXBean yet
// see https://github.com/oracle/graal/issues/6101
return !isJava9OrNewer() || System.getProperty("org.graalvm.nativeimage.imagecode") != null;
Copy link
Contributor

@roberttoyonaga roberttoyonaga Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that GraalVM Native Image would work fine with Threads::java8Callback. Native Image implements some ThreadMXBean functionality, notably all the functionality needed by Threads::java8Callback (see here and here). Although, Threads::java9AndNewerCallback still won't work with Native Image since we don't support ThreadMXBean#getAllThreadIds() or ThreadMXBean.getThreadInfo() yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried JMX - and ran into #13078 (comment)

}

private static Consumer<ObservableLongMeasurement> java8Callback(ThreadMXBean threadBean) {
return measurement -> {
int daemonThreadCount = threadBean.getDaemonThreadCount();