|
23 | 23 | import com.datadog.profiling.controller.oracle.OracleJdkController; |
24 | 24 | import datadog.trace.api.Config; |
25 | 25 | import datadog.trace.api.Platform; |
| 26 | +import datadog.trace.api.config.ProfilingConfig; |
26 | 27 | import datadog.trace.bootstrap.config.provider.ConfigProvider; |
27 | 28 | import de.thetaphi.forbiddenapis.SuppressForbidden; |
28 | 29 | import java.lang.reflect.InvocationTargetException; |
@@ -76,20 +77,25 @@ public static Controller createController(final ConfigProvider configProvider) |
76 | 77 | Implementation impl = Implementation.NONE; |
77 | 78 | boolean isOracleJDK8 = Platform.isOracleJDK8(); |
78 | 79 | boolean isDatadogProfilerEnabled = Config.get().isDatadogProfilerEnabled(); |
79 | | - if (isOracleJDK8 && !isDatadogProfilerEnabled) { |
80 | | - try { |
81 | | - Class.forName("com.oracle.jrockit.jfr.Producer"); |
82 | | - impl = Implementation.ORACLE; |
83 | | - } catch (ClassNotFoundException ignored) { |
84 | | - log.debug("Failed to load oracle profiler", ignored); |
| 80 | + if (ConfigProvider.getInstance() |
| 81 | + .getBoolean(ProfilingConfig.PROFILING_DEBUG_JFR_DISABLED, false)) { |
| 82 | + log.warn("JFR is disabled by configuration"); |
| 83 | + } else { |
| 84 | + if (isOracleJDK8 && !isDatadogProfilerEnabled) { |
| 85 | + try { |
| 86 | + Class.forName("com.oracle.jrockit.jfr.Producer"); |
| 87 | + impl = Implementation.ORACLE; |
| 88 | + } catch (ClassNotFoundException ignored) { |
| 89 | + log.debug("Failed to load oracle profiler", ignored); |
| 90 | + } |
85 | 91 | } |
86 | | - } |
87 | | - if (!isOracleJDK8) { |
88 | | - try { |
89 | | - Class.forName("jdk.jfr.Event"); |
90 | | - impl = Implementation.OPENJDK; |
91 | | - } catch (ClassNotFoundException ignored) { |
92 | | - log.debug("Failed to load openjdk profiler", ignored); |
| 92 | + if (!isOracleJDK8) { |
| 93 | + try { |
| 94 | + Class.forName("jdk.jfr.Event"); |
| 95 | + impl = Implementation.OPENJDK; |
| 96 | + } catch (ClassNotFoundException ignored) { |
| 97 | + log.debug("Failed to load openjdk profiler", ignored); |
| 98 | + } |
93 | 99 | } |
94 | 100 | } |
95 | 101 | if (impl == Implementation.NONE) { |
|
0 commit comments