diff --git a/agent/src/main/java/io/pyroscope/javaagent/AsyncProfilerDelegate.java b/agent/src/main/java/io/pyroscope/javaagent/AsyncProfilerDelegate.java index 143cb6aa..1d1d135b 100644 --- a/agent/src/main/java/io/pyroscope/javaagent/AsyncProfilerDelegate.java +++ b/agent/src/main/java/io/pyroscope/javaagent/AsyncProfilerDelegate.java @@ -74,7 +74,7 @@ public synchronized void stop() { try { instance.stop(); } catch (IllegalStateException e) { - // async-profiler throws when stop is called after the JFR timeout has already elapsed. + // async-profiler throws when stop is called after the recording timeout has already elapsed. if (!PROFILER_NOT_ACTIVE.equals(e.getMessage())) { throw e; } @@ -110,8 +110,10 @@ static String createStartCommand(Config config, Format format, File tempJFRFile) } sb.append(",interval=").append(config.profilingInterval.toNanos()); if (format == Format.JFR) { - sb.append(",file=").append(tempJFRFile.toString()) - .append(",timeout=").append(asyncProfilerTimeoutSeconds(config.uploadInterval)); + sb.append(",file=").append(tempJFRFile.toString()); + } + if (format == Format.JFR || format == Format.OTLP) { + sb.append(",timeout=").append(asyncProfilerTimeoutSeconds(config.uploadInterval)); } if (config.APLogLevel != null) { sb.append(",loglevel=").append(config.APLogLevel); diff --git a/agent/src/test/java/io/pyroscope/javaagent/AsyncProfilerDelegateCommandTest.java b/agent/src/test/java/io/pyroscope/javaagent/AsyncProfilerDelegateCommandTest.java index 3ac8915b..7c9c673b 100644 --- a/agent/src/test/java/io/pyroscope/javaagent/AsyncProfilerDelegateCommandTest.java +++ b/agent/src/test/java/io/pyroscope/javaagent/AsyncProfilerDelegateCommandTest.java @@ -4,6 +4,8 @@ import io.pyroscope.javaagent.config.Config; import org.junit.jupiter.api.Test; +import java.time.Duration; + import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -15,6 +17,7 @@ void otlpStartCommandIncludesConfiguredOptionsWithoutJfrFile() { .setJavaStackDepthMax(1024) .setAPLogLevel("debug") .setAPExtraArguments("threads") + .setUploadInterval(Duration.ofSeconds(10)) .build(); String command = AsyncProfilerDelegate.createStartCommand(config, Format.OTLP, null); @@ -22,6 +25,7 @@ void otlpStartCommandIncludesConfiguredOptionsWithoutJfrFile() { assertTrue(command.contains("jstackdepth=1024")); assertTrue(command.contains("loglevel=debug")); assertTrue(command.contains(",threads")); + assertTrue(command.contains("timeout=11")); assertFalse(command.contains("file=")); } }