1717import datadog .trace .api .Platform ;
1818import datadog .trace .api .config .ProfilingConfig ;
1919import delight .fileupload .FileUpload ;
20+ import io .airlift .compress .zstd .ZstdInputStream ;
2021import java .io .ByteArrayInputStream ;
2122import java .io .File ;
2223import java .io .IOException ;
24+ import java .io .InputStream ;
2325import java .net .InetAddress ;
2426import java .nio .file .Files ;
2527import java .nio .file .Path ;
@@ -150,7 +152,7 @@ void teardown() throws Exception {
150152 }
151153
152154 @ Test
153- @ DisplayName ("Test continuous recording - no jmx delay, no jmethodid cache " )
155+ @ DisplayName ("Test continuous recording - no jmx delay, default compression " )
154156 public void testContinuousRecording_no_jmx_delay (final TestInfo testInfo ) throws Exception {
155157 testWithRetry (
156158 () ->
@@ -161,7 +163,7 @@ public void testContinuousRecording_no_jmx_delay(final TestInfo testInfo) throws
161163 }
162164
163165 @ Test
164- @ DisplayName ("Test continuous recording - no jmx delay, jmethodid cache " )
166+ @ DisplayName ("Test continuous recording - no jmx delay, zstd compression " )
165167 public void testContinuousRecording_no_jmx_delay_jmethodid_cache (final TestInfo testInfo )
166168 throws Exception {
167169 testWithRetry (
@@ -173,7 +175,7 @@ public void testContinuousRecording_no_jmx_delay_jmethodid_cache(final TestInfo
173175 }
174176
175177 @ Test
176- @ DisplayName ("Test continuous recording - 1 sec jmx delay, no jmethodid cache " )
178+ @ DisplayName ("Test continuous recording - 1 sec jmx delay, default compression " )
177179 public void testContinuousRecording (final TestInfo testInfo ) throws Exception {
178180 testWithRetry (
179181 () ->
@@ -184,7 +186,7 @@ public void testContinuousRecording(final TestInfo testInfo) throws Exception {
184186 }
185187
186188 @ Test
187- @ DisplayName ("Test continuous recording - 1 sec jmx delay, jmethodid cache " )
189+ @ DisplayName ("Test continuous recording - 1 sec jmx delay, zstd compression " )
188190 public void testContinuousRecording_jmethodid_cache (final TestInfo testInfo ) throws Exception {
189191 testWithRetry (
190192 () ->
@@ -198,7 +200,7 @@ private void testContinuousRecording(
198200 final int jmxFetchDelay ,
199201 final boolean endpointCollectionEnabled ,
200202 final boolean asyncProfilerEnabled ,
201- final boolean jmethodIdCacheEnabled )
203+ final boolean withZstd )
202204 throws Exception {
203205 final ObjectMapper mapper = new ObjectMapper ();
204206 try {
@@ -207,7 +209,7 @@ private void testContinuousRecording(
207209 jmxFetchDelay ,
208210 endpointCollectionEnabled ,
209211 asyncProfilerEnabled ,
210- jmethodIdCacheEnabled ,
212+ withZstd ,
211213 logFilePath )
212214 .start ();
213215
@@ -261,7 +263,11 @@ private void testContinuousRecording(
261263 assertEquals (InetAddress .getLocalHost ().getHostName (), requestTags .get ("host" ));
262264
263265 assertFalse (logHasErrors (logFilePath ));
264- IItemCollection events = JfrLoaderToolkit .loadEvents (new ByteArrayInputStream (rawJfr .get ()));
266+ InputStream eventStream = new ByteArrayInputStream (rawJfr .get ());
267+ if (withZstd ) {
268+ eventStream = new ZstdInputStream (eventStream );
269+ }
270+ IItemCollection events = JfrLoaderToolkit .loadEvents (eventStream );
265271 assertTrue (events .hasItems ());
266272 Pair <Instant , Instant > rangeStartAndEnd = getRangeStartAndEnd (events );
267273 // This nano-second compensates for the added nano second in
@@ -308,7 +314,11 @@ private void testContinuousRecording(
308314 period > 0 && period <= upperLimit ,
309315 () -> "Upload period = " + period + "ms, expected (0, " + upperLimit + "]ms" );
310316
311- events = JfrLoaderToolkit .loadEvents (new ByteArrayInputStream (rawJfr .get ()));
317+ eventStream = new ByteArrayInputStream (rawJfr .get ());
318+ if (withZstd ) {
319+ eventStream = new ZstdInputStream (eventStream );
320+ }
321+ events = JfrLoaderToolkit .loadEvents (eventStream );
312322 assertTrue (events .hasItems ());
313323 verifyDatadogEventsNotCorrupt (events );
314324 rangeStartAndEnd = getRangeStartAndEnd (events );
@@ -689,7 +699,7 @@ private ProcessBuilder createDefaultProcessBuilder(
689699 final int jmxFetchDelay ,
690700 final boolean endpointCollectionEnabled ,
691701 final boolean asyncProfilerEnabled ,
692- final boolean jmethodIdCacheEnabled ,
702+ final boolean withZstd ,
693703 final Path logFilePath ) {
694704 return createProcessBuilder (
695705 VALID_API_KEY ,
@@ -698,7 +708,7 @@ private ProcessBuilder createDefaultProcessBuilder(
698708 PROFILING_UPLOAD_PERIOD_SECONDS ,
699709 endpointCollectionEnabled ,
700710 asyncProfilerEnabled ,
701- jmethodIdCacheEnabled ,
711+ withZstd ,
702712 0 ,
703713 logFilePath );
704714 }
@@ -710,7 +720,7 @@ private ProcessBuilder createProcessBuilder(
710720 final int profilingUploadPeriodSecs ,
711721 final boolean endpointCollectionEnabled ,
712722 final boolean asyncProfilerEnabled ,
713- final boolean jmethodIdCacheEnabled ,
723+ final boolean withZstd ,
714724 final int exitDelay ,
715725 final Path logFilePath ) {
716726 return createProcessBuilder (
@@ -722,7 +732,7 @@ private ProcessBuilder createProcessBuilder(
722732 profilingUploadPeriodSecs ,
723733 endpointCollectionEnabled ,
724734 asyncProfilerEnabled ,
725- jmethodIdCacheEnabled ,
735+ withZstd ,
726736 exitDelay ,
727737 logFilePath );
728738 }
@@ -736,7 +746,7 @@ private static ProcessBuilder createProcessBuilder(
736746 final int profilingUploadPeriodSecs ,
737747 final boolean endpointCollectionEnabled ,
738748 final boolean asyncProfilerEnabled ,
739- final boolean jmethodIdCacheEnabled ,
749+ final boolean withZstd ,
740750 final int exitDelay ,
741751 final Path logFilePath ) {
742752 final String templateOverride =
@@ -770,7 +780,7 @@ private static ProcessBuilder createProcessBuilder(
770780 "-Ddd.profiling.debug.dump_path=/tmp/dd-profiler" ,
771781 "-Ddd.profiling.queueing.time.enabled=true" ,
772782 "-Ddd.profiling.queueing.time.threshold.millis=0" ,
773- "-Ddd.profiling.experimental.jmethodid_cache.enabled =" + jmethodIdCacheEnabled ,
783+ "-Ddd.profiling.debug.upload.compression =" + ( withZstd ? "zstd" : "on" ) ,
774784 "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug" ,
775785 "-Ddd.profiling.context.attributes=foo,bar" ,
776786 "-Dorg.slf4j.simpleLogger.defaultLogLevel=debug" ,
0 commit comments