17
17
import datadog .trace .api .Platform ;
18
18
import datadog .trace .api .config .ProfilingConfig ;
19
19
import delight .fileupload .FileUpload ;
20
+ import io .airlift .compress .zstd .ZstdInputStream ;
20
21
import java .io .ByteArrayInputStream ;
21
22
import java .io .File ;
22
23
import java .io .IOException ;
24
+ import java .io .InputStream ;
23
25
import java .net .InetAddress ;
24
26
import java .nio .file .Files ;
25
27
import java .nio .file .Path ;
@@ -150,7 +152,7 @@ void teardown() throws Exception {
150
152
}
151
153
152
154
@ Test
153
- @ DisplayName ("Test continuous recording - no jmx delay, no jmethodid cache " )
155
+ @ DisplayName ("Test continuous recording - no jmx delay, default compression " )
154
156
public void testContinuousRecording_no_jmx_delay (final TestInfo testInfo ) throws Exception {
155
157
testWithRetry (
156
158
() ->
@@ -161,7 +163,7 @@ public void testContinuousRecording_no_jmx_delay(final TestInfo testInfo) throws
161
163
}
162
164
163
165
@ Test
164
- @ DisplayName ("Test continuous recording - no jmx delay, jmethodid cache " )
166
+ @ DisplayName ("Test continuous recording - no jmx delay, zstd compression " )
165
167
public void testContinuousRecording_no_jmx_delay_jmethodid_cache (final TestInfo testInfo )
166
168
throws Exception {
167
169
testWithRetry (
@@ -173,7 +175,7 @@ public void testContinuousRecording_no_jmx_delay_jmethodid_cache(final TestInfo
173
175
}
174
176
175
177
@ Test
176
- @ DisplayName ("Test continuous recording - 1 sec jmx delay, no jmethodid cache " )
178
+ @ DisplayName ("Test continuous recording - 1 sec jmx delay, default compression " )
177
179
public void testContinuousRecording (final TestInfo testInfo ) throws Exception {
178
180
testWithRetry (
179
181
() ->
@@ -184,7 +186,7 @@ public void testContinuousRecording(final TestInfo testInfo) throws Exception {
184
186
}
185
187
186
188
@ Test
187
- @ DisplayName ("Test continuous recording - 1 sec jmx delay, jmethodid cache " )
189
+ @ DisplayName ("Test continuous recording - 1 sec jmx delay, zstd compression " )
188
190
public void testContinuousRecording_jmethodid_cache (final TestInfo testInfo ) throws Exception {
189
191
testWithRetry (
190
192
() ->
@@ -198,7 +200,7 @@ private void testContinuousRecording(
198
200
final int jmxFetchDelay ,
199
201
final boolean endpointCollectionEnabled ,
200
202
final boolean asyncProfilerEnabled ,
201
- final boolean jmethodIdCacheEnabled )
203
+ final boolean withZstd )
202
204
throws Exception {
203
205
final ObjectMapper mapper = new ObjectMapper ();
204
206
try {
@@ -207,7 +209,7 @@ private void testContinuousRecording(
207
209
jmxFetchDelay ,
208
210
endpointCollectionEnabled ,
209
211
asyncProfilerEnabled ,
210
- jmethodIdCacheEnabled ,
212
+ withZstd ,
211
213
logFilePath )
212
214
.start ();
213
215
@@ -261,7 +263,11 @@ private void testContinuousRecording(
261
263
assertEquals (InetAddress .getLocalHost ().getHostName (), requestTags .get ("host" ));
262
264
263
265
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 );
265
271
assertTrue (events .hasItems ());
266
272
Pair <Instant , Instant > rangeStartAndEnd = getRangeStartAndEnd (events );
267
273
// This nano-second compensates for the added nano second in
@@ -308,7 +314,11 @@ private void testContinuousRecording(
308
314
period > 0 && period <= upperLimit ,
309
315
() -> "Upload period = " + period + "ms, expected (0, " + upperLimit + "]ms" );
310
316
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 );
312
322
assertTrue (events .hasItems ());
313
323
verifyDatadogEventsNotCorrupt (events );
314
324
rangeStartAndEnd = getRangeStartAndEnd (events );
@@ -689,7 +699,7 @@ private ProcessBuilder createDefaultProcessBuilder(
689
699
final int jmxFetchDelay ,
690
700
final boolean endpointCollectionEnabled ,
691
701
final boolean asyncProfilerEnabled ,
692
- final boolean jmethodIdCacheEnabled ,
702
+ final boolean withZstd ,
693
703
final Path logFilePath ) {
694
704
return createProcessBuilder (
695
705
VALID_API_KEY ,
@@ -698,7 +708,7 @@ private ProcessBuilder createDefaultProcessBuilder(
698
708
PROFILING_UPLOAD_PERIOD_SECONDS ,
699
709
endpointCollectionEnabled ,
700
710
asyncProfilerEnabled ,
701
- jmethodIdCacheEnabled ,
711
+ withZstd ,
702
712
0 ,
703
713
logFilePath );
704
714
}
@@ -710,7 +720,7 @@ private ProcessBuilder createProcessBuilder(
710
720
final int profilingUploadPeriodSecs ,
711
721
final boolean endpointCollectionEnabled ,
712
722
final boolean asyncProfilerEnabled ,
713
- final boolean jmethodIdCacheEnabled ,
723
+ final boolean withZstd ,
714
724
final int exitDelay ,
715
725
final Path logFilePath ) {
716
726
return createProcessBuilder (
@@ -722,7 +732,7 @@ private ProcessBuilder createProcessBuilder(
722
732
profilingUploadPeriodSecs ,
723
733
endpointCollectionEnabled ,
724
734
asyncProfilerEnabled ,
725
- jmethodIdCacheEnabled ,
735
+ withZstd ,
726
736
exitDelay ,
727
737
logFilePath );
728
738
}
@@ -736,7 +746,7 @@ private static ProcessBuilder createProcessBuilder(
736
746
final int profilingUploadPeriodSecs ,
737
747
final boolean endpointCollectionEnabled ,
738
748
final boolean asyncProfilerEnabled ,
739
- final boolean jmethodIdCacheEnabled ,
749
+ final boolean withZstd ,
740
750
final int exitDelay ,
741
751
final Path logFilePath ) {
742
752
final String templateOverride =
@@ -770,7 +780,7 @@ private static ProcessBuilder createProcessBuilder(
770
780
"-Ddd.profiling.debug.dump_path=/tmp/dd-profiler" ,
771
781
"-Ddd.profiling.queueing.time.enabled=true" ,
772
782
"-Ddd.profiling.queueing.time.threshold.millis=0" ,
773
- "-Ddd.profiling.experimental.jmethodid_cache.enabled =" + jmethodIdCacheEnabled ,
783
+ "-Ddd.profiling.debug.upload.compression =" + ( withZstd ? "zstd" : "on" ) ,
774
784
"-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug" ,
775
785
"-Ddd.profiling.context.attributes=foo,bar" ,
776
786
"-Dorg.slf4j.simpleLogger.defaultLogLevel=debug" ,
0 commit comments