You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/08/09 00:29:21 UTC

[GitHub] [skywalking] wu-sheng commented on a change in pull request #5274: make CPUMetricsAccessor SPI switchable and suppport other jvm

wu-sheng commented on a change in pull request #5274:
URL: https://github.com/apache/skywalking/pull/5274#discussion_r467518542



##########
File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUProvider.java
##########
@@ -30,10 +30,11 @@
     CPUProvider() {
         int processorNum = ProcessorUtil.getNumberOfProcessors();
         try {
-            this.cpuMetricsAccessor = (CPUMetricsAccessor) CPUProvider.class.getClassLoader()
-                                                                            .loadClass("org.apache.skywalking.apm.agent.core.jvm.cpu.SunCpuAccessor")
-                                                                            .getConstructor(int.class)
-                                                                            .newInstance(processorNum);
+            //-Dskywalking.cpu_provider=org.apache.skywalking.apm.agent.core.jvm.cpu.JmxCpuAccessor
+            final String cpuAccessorCls = System.getProperty("skywalking.cpu_provider",

Review comment:
       This is a wrong way to extend. 
   
   1. System properties are supported for config injection in the Config.java.
   1. Why use try catch and config at the same time?
   1. Take a reference from memory gc access. The different accessors should be used based on JVM automatical detection.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org