Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import datadog.trace.relocate.api.IOLogger;
import datadog.trace.util.PidHelper;
import delight.fileupload.FileUpload;
import io.airlift.compress.zstd.ZstdInputStream;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -337,7 +338,7 @@ public void testZippedInput() throws Exception {
}

@ParameterizedTest
@ValueSource(strings = {"on", "lz4", "gzip", "off", "invalid"})
@ValueSource(strings = {"on", "lz4", "gzip", "zstd", "off", "invalid"})
public void testCompression(final String compression) throws Exception {
when(config.getApiKey()).thenReturn(null);
when(config.getProfilingUploadCompression()).thenReturn(compression);
Expand Down Expand Up @@ -372,6 +373,8 @@ public void testCompression(final String compression) throws Exception {
byte[] uploadedBytes = rawJfr.get();
if (compression.equals("gzip")) {
uploadedBytes = unGzip(uploadedBytes);
} else if (compression.equals("zstd")) {
uploadedBytes = unZstd(uploadedBytes);
} else if (compression.equals("on")
|| compression.equals("lz4")
|| compression.equals("invalid")) {
Expand Down Expand Up @@ -895,6 +898,13 @@ private static byte[] unLz4(final byte[] compressed) throws IOException {
return result.toByteArray();
}

private static byte[] unZstd(final byte[] compressed) throws IOException {
final InputStream stream = new ZstdInputStream(new ByteArrayInputStream(compressed));
final ByteArrayOutputStream result = new ByteArrayOutputStream();
ByteStreams.copy(stream, result);
return result.toByteArray();
}

private void uploadAndWait(final RecordingType recordingType, final RecordingData data)
throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
Expand Down