|
1 | 1 | package datadog.trace.api; |
2 | 2 |
|
| 3 | +import static datadog.environment.JavaVirtualMachine.isJavaVersion; |
| 4 | +import static datadog.environment.JavaVirtualMachine.isJavaVersionAtLeast; |
3 | 5 | import static datadog.trace.api.ConfigDefaults.DEFAULT_ADD_SPAN_POINTERS; |
4 | 6 | import static datadog.trace.api.ConfigDefaults.DEFAULT_AGENT_HOST; |
5 | 7 | import static datadog.trace.api.ConfigDefaults.DEFAULT_AGENT_TIMEOUT; |
|
609 | 611 | import static datadog.trace.util.CollectionUtils.tryMakeImmutableSet; |
610 | 612 | import static datadog.trace.util.Strings.propertyNameToEnvironmentVariableName; |
611 | 613 |
|
| 614 | +import datadog.environment.JavaVirtualMachine; |
| 615 | +import datadog.environment.OperatingSystem; |
612 | 616 | import datadog.trace.api.civisibility.CiVisibilityWellKnownTags; |
613 | 617 | import datadog.trace.api.config.GeneralConfig; |
614 | 618 | import datadog.trace.api.config.ProfilingConfig; |
@@ -3299,41 +3303,41 @@ public boolean isDatadogProfilerEnabled() { |
3299 | 3303 | public static boolean isDatadogProfilerEnablementOverridden() { |
3300 | 3304 | // old non-LTS versions without important backports |
3301 | 3305 | // also, we have no windows binaries |
3302 | | - return Platform.isWindows() |
3303 | | - || Platform.isJavaVersion(18) |
3304 | | - || Platform.isJavaVersion(16) |
3305 | | - || Platform.isJavaVersion(15) |
3306 | | - || Platform.isJavaVersion(14) |
3307 | | - || Platform.isJavaVersion(13) |
3308 | | - || Platform.isJavaVersion(12) |
3309 | | - || Platform.isJavaVersion(10) |
3310 | | - || Platform.isJavaVersion(9); |
| 3306 | + return OperatingSystem.isWindows() |
| 3307 | + || isJavaVersion(18) |
| 3308 | + || isJavaVersion(16) |
| 3309 | + || isJavaVersion(15) |
| 3310 | + || isJavaVersion(14) |
| 3311 | + || isJavaVersion(13) |
| 3312 | + || isJavaVersion(12) |
| 3313 | + || isJavaVersion(10) |
| 3314 | + || isJavaVersion(9); |
3311 | 3315 | } |
3312 | 3316 |
|
3313 | 3317 | public static boolean isDatadogProfilerSafeInCurrentEnvironment() { |
3314 | 3318 | // don't want to put this logic (which will evolve) in the public ProfilingConfig, and can't |
3315 | 3319 | // access Platform there |
3316 | | - if (!Platform.isJ9() && Platform.isJavaVersion(8)) { |
| 3320 | + if (!JavaVirtualMachine.isJ9() && isJavaVersion(8)) { |
3317 | 3321 | String arch = System.getProperty("os.arch"); |
3318 | 3322 | if ("aarch64".equalsIgnoreCase(arch) || "arm64".equalsIgnoreCase(arch)) { |
3319 | 3323 | return false; |
3320 | 3324 | } |
3321 | 3325 | } |
3322 | | - if (Platform.isGraalVM()) { |
| 3326 | + if (JavaVirtualMachine.isGraalVM()) { |
3323 | 3327 | // let's be conservative about GraalVM and require opt-in from the users |
3324 | 3328 | return false; |
3325 | 3329 | } |
3326 | 3330 | boolean result = false; |
3327 | | - if (Platform.isJ9()) { |
| 3331 | + if (JavaVirtualMachine.isJ9()) { |
3328 | 3332 | // OpenJ9 will activate only JVMTI GetAllStackTraces based profiling which is safe |
3329 | 3333 | result = true; |
3330 | 3334 | } else { |
3331 | 3335 | // JDK 18 is missing ASGCT fixes, so we can't use it |
3332 | | - if (!Platform.isJavaVersion(18)) { |
| 3336 | + if (!isJavaVersion(18)) { |
3333 | 3337 | result = |
3334 | | - Platform.isJavaVersionAtLeast(17, 0, 5) |
3335 | | - || (Platform.isJavaVersion(11) && Platform.isJavaVersionAtLeast(11, 0, 17)) |
3336 | | - || (Platform.isJavaVersion(8) && Platform.isJavaVersionAtLeast(8, 0, 352)); |
| 3338 | + isJavaVersionAtLeast(17, 0, 5) |
| 3339 | + || (isJavaVersion(11) && isJavaVersionAtLeast(11, 0, 17)) |
| 3340 | + || (isJavaVersion(8) && isJavaVersionAtLeast(8, 0, 352)); |
3337 | 3341 | } |
3338 | 3342 | } |
3339 | 3343 | return result; |
|
0 commit comments