diff --git a/dd-java-agent/agent-profiling/profiling-ddprof/src/main/java/com/datadog/profiling/ddprof/DatadogProfiler.java b/dd-java-agent/agent-profiling/profiling-ddprof/src/main/java/com/datadog/profiling/ddprof/DatadogProfiler.java index 15b524b32d4..ad56ca81a74 100644 --- a/dd-java-agent/agent-profiling/profiling-ddprof/src/main/java/com/datadog/profiling/ddprof/DatadogProfiler.java +++ b/dd-java-agent/agent-profiling/profiling-ddprof/src/main/java/com/datadog/profiling/ddprof/DatadogProfiler.java @@ -22,6 +22,7 @@ import static com.datadog.profiling.ddprof.DatadogProfilerConfig.isTrackingGenerations; import static com.datadog.profiling.ddprof.DatadogProfilerConfig.isWallClockProfilerEnabled; import static com.datadog.profiling.ddprof.DatadogProfilerConfig.omitLineNumbers; +import static com.datadog.profiling.ddprof.DatadogProfilerConfig.useJvmtiWallclockSampler; import static com.datadog.profiling.utils.ProfilingMode.ALLOCATION; import static com.datadog.profiling.utils.ProfilingMode.CPU; import static com.datadog.profiling.utils.ProfilingMode.MEMLEAK; @@ -271,6 +272,9 @@ String cmdStartProfiling(Path file) throws IllegalStateException { if (getWallContextFilter(configProvider)) { cmd.append(",filter=0"); } + if (useJvmtiWallclockSampler(configProvider)) { + cmd.append(",wallsampler=jvmti"); + } } cmd.append(",loglevel=").append(getLogLevel(configProvider)); if (profilingModes.contains(ALLOCATION) || profilingModes.contains(MEMLEAK)) { diff --git a/dd-java-agent/agent-profiling/profiling-ddprof/src/main/java/com/datadog/profiling/ddprof/DatadogProfilerConfig.java b/dd-java-agent/agent-profiling/profiling-ddprof/src/main/java/com/datadog/profiling/ddprof/DatadogProfilerConfig.java index 586435f5f44..4e161dada37 100644 --- a/dd-java-agent/agent-profiling/profiling-ddprof/src/main/java/com/datadog/profiling/ddprof/DatadogProfilerConfig.java +++ b/dd-java-agent/agent-profiling/profiling-ddprof/src/main/java/com/datadog/profiling/ddprof/DatadogProfilerConfig.java @@ -43,6 +43,8 @@ import static datadog.trace.api.config.ProfilingConfig.PROFILING_DATADOG_PROFILER_WALL_ENABLED; import static datadog.trace.api.config.ProfilingConfig.PROFILING_DATADOG_PROFILER_WALL_INTERVAL; import static datadog.trace.api.config.ProfilingConfig.PROFILING_DATADOG_PROFILER_WALL_INTERVAL_DEFAULT; +import static datadog.trace.api.config.ProfilingConfig.PROFILING_DATADOG_PROFILER_WALL_JVMTI; +import static datadog.trace.api.config.ProfilingConfig.PROFILING_DATADOG_PROFILER_WALL_JVMTI_DEFAULT; import static datadog.trace.api.config.ProfilingConfig.PROFILING_HEAP_TRACK_GENERATIONS; import static datadog.trace.api.config.ProfilingConfig.PROFILING_HEAP_TRACK_GENERATIONS_DEFAULT; import static datadog.trace.api.config.ProfilingConfig.PROFILING_QUEUEING_TIME_ENABLED; @@ -409,6 +411,14 @@ public static long getLong(ConfigProvider configProvider, String key) { return configProvider.getLong(key, configProvider.getLong(normalizeKey(key), -1)); } + public static boolean useJvmtiWallclockSampler(ConfigProvider configProvider) { + return !isWallClockProfilerEnabled(configProvider) + && getBoolean( + configProvider, + PROFILING_DATADOG_PROFILER_WALL_JVMTI, + PROFILING_DATADOG_PROFILER_WALL_JVMTI_DEFAULT); + } + private static String normalizeKey(String key) { return key.replace(".ddprof.", ".async."); } diff --git a/dd-trace-api/src/main/java/datadog/trace/api/config/ProfilingConfig.java b/dd-trace-api/src/main/java/datadog/trace/api/config/ProfilingConfig.java index 0c7711b2405..40873fc5ad6 100644 --- a/dd-trace-api/src/main/java/datadog/trace/api/config/ProfilingConfig.java +++ b/dd-trace-api/src/main/java/datadog/trace/api/config/ProfilingConfig.java @@ -116,6 +116,10 @@ public final class ProfilingConfig { "profiling.ddprof.wall.context.filter"; public static final boolean PROFILING_DATADOG_PROFILER_WALL_CONTEXT_FILTER_DEFAULT = true; + public static final String PROFILING_DATADOG_PROFILER_WALL_JVMTI = + "profiling.experimental.ddprof.wall.jvmti"; + public static final boolean PROFILING_DATADOG_PROFILER_WALL_JVMTI_DEFAULT = false; + public static final String PROFILING_DATADOG_PROFILER_SCHEDULING_EVENT = "profiling.experimental.ddprof.scheduling.event"; diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8026189c17e..1f4d82334cc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -29,7 +29,7 @@ moshi = '1.11.0' testcontainers = '1.19.3' jmc = "8.1.0" autoservice = "1.0-rc7" -ddprof = "1.13.0" +ddprof = "1.14.0" asm = "9.7" cafe_crypto = "0.1.0" lz4 = "1.7.1"