Skip to content
Merged
Show file tree
Hide file tree
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 @@ -28,7 +28,7 @@ public static void premain(String agentArgs, Instrumentation inst) {
if(!createFileIfNotExist("/tmp/aws-lambda-java-profiler")) {
Logger.debug("starting the profiler for coldstart");
startProfiler();
registerShutdownHook(AsyncProfiler.getInstance());
registerShutdownHook();
try {
Integer port = Integer.parseInt(INTERNAL_COMMUNICATION_PORT);
Logger.debug("using profile communication port = " + port);
Expand Down Expand Up @@ -101,9 +101,9 @@ public static void startProfiler() {
}
}

public static void registerShutdownHook(AsyncProfiler profiler) {
public static void registerShutdownHook() {
Logger.debug("registering shutdown hook");
Thread shutdownHook = new Thread(new ShutdownHook(profiler));
Thread shutdownHook = new Thread(new ShutdownHook(PROFILER_STOP_COMMAND));
Runtime.getRuntime().addShutdownHook(shutdownHook);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

public class ShutdownHook implements Runnable {

private AsyncProfiler profiler;
private String stopCommand;

public ShutdownHook(AsyncProfiler profiler) {
this.profiler = profiler;
public ShutdownHook(String stopCommand) {
this.stopCommand = stopCommand;
}

@Override
Expand All @@ -18,7 +18,7 @@ public void run() {
try {
final String fileName = "/tmp/profiling-data-shutdown.html";
Logger.debug("stopping the profiler");
AsyncProfiler.getInstance().execute(String.format("stop,file=%s,include=*AWSLambda.main,include=start_thread", fileName));
AsyncProfiler.getInstance().execute(String.format(this.stopCommand, fileName));
} catch (Exception e) {
Logger.error("could not stop the profiler");
}
Expand Down