mirror of
https://github.com/async-profiler/async-profiler.git
synced 2026-04-28 02:53:00 +00:00
dumpOtlp() should accept Counter argument (#1728)
This commit is contained in:
@@ -201,7 +201,7 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
|
||||
@Override
|
||||
public String dumpCollapsed(Counter counter) {
|
||||
try {
|
||||
return execute0("collapsed," + counter.name().toLowerCase());
|
||||
return execute0("collapsed," + (counter == Counter.SAMPLES ? "samples" : "total"));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
@@ -242,12 +242,13 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
|
||||
* <p>
|
||||
* This API is UNSTABLE and might change or be removed in the next version of async-profiler.
|
||||
*
|
||||
* @param counter Which counter to use for aggregation
|
||||
* @return OTLP representation of the profile
|
||||
*/
|
||||
@Override
|
||||
public byte[] dumpOtlp() {
|
||||
public byte[] dumpOtlp(Counter counter) {
|
||||
try {
|
||||
return execute1("otlp");
|
||||
return execute1("otlp," + (counter == Counter.SAMPLES ? "samples" : "total"));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ public interface AsyncProfilerMXBean {
|
||||
String dumpCollapsed(Counter counter);
|
||||
String dumpTraces(int maxTraces);
|
||||
String dumpFlat(int maxMethods);
|
||||
byte[] dumpOtlp();
|
||||
byte[] dumpOtlp(Counter counter);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package test.api;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import one.profiler.AsyncProfiler;
|
||||
import one.profiler.Counter;
|
||||
import one.profiler.Events;
|
||||
@@ -22,7 +21,7 @@ public class DumpOtlp extends BusyLoops {
|
||||
}
|
||||
|
||||
// TODO: Should we test this further?
|
||||
byte[] profile = AsyncProfiler.getInstance().dumpOtlp();
|
||||
byte[] profile = AsyncProfiler.getInstance().dumpOtlp(Counter.TOTAL);
|
||||
System.out.println(profile.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package test.otlp;
|
||||
|
||||
import one.profiler.AsyncProfiler;
|
||||
import one.profiler.Counter;
|
||||
import one.profiler.Events;
|
||||
import io.opentelemetry.proto.profiles.v1development.*;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class OtlpProfileTimeTest {
|
||||
}
|
||||
|
||||
public static Profile dumpAndGetProfile(AsyncProfiler profiler) throws Exception {
|
||||
byte[] dump = profiler.dumpOtlp();
|
||||
byte[] dump = profiler.dumpOtlp(Counter.SAMPLES);
|
||||
ProfilesData data = ProfilesData.parseFrom(dump);
|
||||
return data.getResourceProfiles(0).getScopeProfiles(0).getProfiles(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user