Switch-vov commented on a change in pull request #7243:
URL: https://github.com/apache/skywalking/pull/7243#discussion_r663921176



##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/thread/ThreadProvider.java
##########
@@ -31,12 +32,58 @@
     }
 
     public Thread getThreadMetrics() {
+        int newStateThreadCount = 0;
+        int runnableStateThreadCount = 0;
+        int blockedStateThreadCount = 0;
+        int waitingStateThreadCount = 0;
+        int timedWaitingStateThreadCount = 0;
+        int terminatedStateThreadCount = 0;
+
+        ThreadInfo[] threadInfos = 
threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds(), 0);
+        if (threadInfos != null) {
+            for (ThreadInfo threadInfo : threadInfos) {
+                if (threadInfo != null) {
+                    switch (threadInfo.getThreadState()) {
+                        case NEW:
+                            newStateThreadCount++;
+                            break;
+                        case RUNNABLE:
+                            runnableStateThreadCount++;
+                            break;
+                        case BLOCKED:
+                            blockedStateThreadCount++;
+                            break;
+                        case WAITING:
+                            waitingStateThreadCount++;
+                            break;
+                        case TIMED_WAITING:
+                            timedWaitingStateThreadCount++;
+                            break;
+                        case TERMINATED:
+                            terminatedStateThreadCount++;
+                            break;
+                        default:
+                            break;
+                    }
+                } else {
+                    terminatedStateThreadCount++;
+                }

Review comment:
       > So we need to consider whether we want to remove them.
   
   `New State` is zero always, but `Terminated State` is non-zero sometimes.
   
   So, I should remove them?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to