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

Fill jvm.thread.state attribute for jvm.thread.count metric on jdk8 #12724

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Nov 13, 2024

Related to #12614 and #11980
Currently on jdk8 we don't fill jvm.thread.state attribute because through the jmx apis on jdk 8 we can't get jvm.thread.state and jvm.thread.daemon at the same time. This PR provides an alternative implementation based on java.lang.Thread that can fill both of these attributes on jdk8.

@laurit laurit requested a review from a team as a code owner November 13, 2024 14:04

// Visible for testing
static Thread[] getThreads() {
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

initially I planned to use reflection to call Thread.getThreads(), but that method is not available on openj9

}

// Visible for testing
List<AutoCloseable> registerObservers(OpenTelemetry openTelemetry, ThreadMXBean threadBean) {
return registerObservers(
openTelemetry,
isJava9OrNewer() ? Threads::java9AndNewerCallback : Threads::java8Callback,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the java8Callback is only used in tests

@trask trask merged commit 6bafd2b into open-telemetry:main Nov 15, 2024
56 checks passed
akats7 pushed a commit to akats7/opentelemetry-java-instrumentation that referenced this pull request Nov 21, 2024
akats7 pushed a commit to akats7/opentelemetry-java-instrumentation that referenced this pull request Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants