Skip to content

Commit

Permalink
chore: remove collapsed format (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
korniltsev authored Feb 9, 2024
1 parent eca2487 commit f70fa46
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
2 changes: 0 additions & 2 deletions agent/src/main/java/io/pyroscope/http/Format.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.pyroscope.http;

public enum Format {
@Deprecated // use jfr
COLLAPSED ("collapsed"),
JFR ("jfr");

/**
Expand Down
5 changes: 0 additions & 5 deletions agent/src/main/java/io/pyroscope/javaagent/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ public final class Config {
DefaultLogger.PRECONFIG_LOGGER.log(Logger.Level.WARN,
"Setting PYROSCOPE_PROFILER_LOCK to 0 registers every lock event, causing significant overhead and results in large profiles, making it not ideal for production. We recommend a starting value of 10ms, adjusting as needed.");
}
if (format == Format.COLLAPSED) {
DefaultLogger.PRECONFIG_LOGGER.log(Logger.Level.WARN, "COLLAPSED format is deprecated");
}
}

public long profilingIntervalInHertz() {
Expand Down Expand Up @@ -480,8 +477,6 @@ private static Format format(ConfigurationProvider configurationProvider) {
if (format == null || format.isEmpty())
return DEFAULT_FORMAT;
switch (format.trim().toLowerCase()) {
case "collapsed":
return Format.COLLAPSED;
case "jfr":
return Format.JFR;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,24 @@ private void uploadSnapshot(final Snapshot snapshot) throws InterruptedException
while (retry) {
tries++;
final RequestBody requestBody;
if (config.format == Format.JFR) {
byte[] labels = snapshot.labels.toByteArray();
logger.log(Logger.Level.DEBUG, "Upload attempt %d to %s. %s %s JFR: %s, labels: %s", tries, url.toString(),
snapshot.started.toString(), snapshot.ended.toString(), snapshot.data.length, labels.length);
MultipartBody.Builder bodyBuilder = new MultipartBody.Builder()
.setType(MultipartBody.FORM);
RequestBody jfrBody = RequestBody.create(snapshot.data);
if (config.compressionLevelJFR != Deflater.NO_COMPRESSION) {
jfrBody = GzipSink.gzip(jfrBody, config.compressionLevelJFR);
}
bodyBuilder.addFormDataPart("jfr", "jfr", jfrBody);
if (labels.length > 0) {
RequestBody labelsBody = RequestBody.create(labels, PROTOBUF);
if (config.compressionLevelLabels != Deflater.NO_COMPRESSION) {
labelsBody = GzipSink.gzip(labelsBody, config.compressionLevelLabels);
}
bodyBuilder.addFormDataPart("labels", "labels", labelsBody);
byte[] labels = snapshot.labels.toByteArray();
logger.log(Logger.Level.DEBUG, "Upload attempt %d to %s. %s %s JFR: %s, labels: %s", tries, url.toString(),
snapshot.started.toString(), snapshot.ended.toString(), snapshot.data.length, labels.length);
MultipartBody.Builder bodyBuilder = new MultipartBody.Builder()
.setType(MultipartBody.FORM);
RequestBody jfrBody = RequestBody.create(snapshot.data);
if (config.compressionLevelJFR != Deflater.NO_COMPRESSION) {
jfrBody = GzipSink.gzip(jfrBody, config.compressionLevelJFR);
}
bodyBuilder.addFormDataPart("jfr", "jfr", jfrBody);
if (labels.length > 0) {
RequestBody labelsBody = RequestBody.create(labels, PROTOBUF);
if (config.compressionLevelLabels != Deflater.NO_COMPRESSION) {
labelsBody = GzipSink.gzip(labelsBody, config.compressionLevelLabels);
}
requestBody = bodyBuilder.build();
} else {
logger.log(Logger.Level.DEBUG, "Upload attempt %d to %s. collapsed: %s", tries, url.toString(), snapshot.data.length);
requestBody = RequestBody.create(snapshot.data);
bodyBuilder.addFormDataPart("labels", "labels", labelsBody);
}
requestBody = bodyBuilder.build();
Request.Builder request = new Request.Builder()
.post(requestBody)
.url(url);
Expand Down Expand Up @@ -153,8 +148,7 @@ private HttpUrl urlForSnapshot(final Snapshot snapshot) {
.addQueryParameter("spyName", Config.DEFAULT_SPY_NAME);
if (EventType.CPU == snapshot.eventType || EventType.ITIMER == snapshot.eventType || EventType.WALL == snapshot.eventType)
builder.addQueryParameter("sampleRate", Long.toString(config.profilingIntervalInHertz()));
if (config.format == Format.JFR)
builder.addQueryParameter("format", "jfr");
builder.addQueryParameter("format", "jfr");
return builder.build();
}

Expand Down

0 comments on commit f70fa46

Please sign in to comment.