Skip to content

Commit

Permalink
add support for leak profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Sisso committed Nov 28, 2022
1 parent bdb481a commit f7a33fc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.taboola</groupId>
<artifactId>async-profiler-actuator-endpoint</artifactId>
<version>2.0.1_${async.profiler.version}</version>
<version>2.0.2_${async.profiler.version}</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Async Profiler Actuator Endpoint</description>
Expand Down Expand Up @@ -51,7 +51,7 @@
<com.taboola.spring.version>4.3.23.RELEASE</com.taboola.spring.version>
<com.taboola.spring.boot.version>1.5.20.RELEASE</com.taboola.spring.boot.version>
<com.taboola.lombok.version>1.18.10</com.taboola.lombok.version>
<async.profiler.version>2.7</async.profiler.version>
<async.profiler.version>2.9</async.profiler.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<skip.bootstrap>false</skip.bootstrap>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public String createStartCommand(ProfileRequest profileRequest, String filePath)
stringBuilder.append(interval);
}

if (profileRequest.getEvents().contains(Events.ALLOC) && profileRequest.isLiveObjectsOnly()) {
stringBuilder.append(",live");
}

if (profileRequest.getJfrSync() != null) {
if (profileRequest.getJfrSync().isEmpty()) {
stringBuilder.append(",jfrsync");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ProfileRequest {
Integer samplingInterval = 1;
TimeUnit samplingIntervalTimeUnit = TimeUnit.MILLISECONDS;
Integer allocIntervalBytes = 10_000;//relevant only for alloc event.
boolean liveObjectsOnly = true;
Integer lockThresholdNanos = 1;//relevant only for lock event.
boolean separateThreads = false;
String includedThreads;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testCreateStartCommandWithMultipleEvents() {
profileRequest.setSamplingIntervalTimeUnit(TimeUnit.NANOSECONDS);
String command = commandFactory.createStartCommand(profileRequest, file);

assertEquals("start,event=cpu,alloc=10000,lock=1,file=f,jfr,interval=1", command);
assertEquals("start,event=cpu,alloc=10000,lock=1,file=f,jfr,interval=1,live", command);
}

@Test
Expand All @@ -94,6 +94,19 @@ public void testCreateStartCommand_whenEventIsAlloc_intervalShouldBeTakenFromInt
profileRequest.setAllocIntervalBytes(2);
String command = commandFactory.createStartCommand(profileRequest, file);

assertEquals("start,event=alloc,alloc=2,file=f,flamegraph,interval=1000000,live", command);
}

@Test
public void testCreateStartCommand_whenEventIsAllocAndLiveObjectsOnlyIsFalse() {
String file = "f";
ProfileRequest profileRequest = new ProfileRequest();
profileRequest.setEvents(new HashSet<String>(){{add(Events.ALLOC);}});
profileRequest.setSamplingInterval(1);
profileRequest.setAllocIntervalBytes(2);
profileRequest.setLiveObjectsOnly(false);
String command = commandFactory.createStartCommand(profileRequest, file);

assertEquals("start,event=alloc,alloc=2,file=f,flamegraph,interval=1000000", command);
}

Expand Down

0 comments on commit f7a33fc

Please sign in to comment.