Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEZ-4487: Add class name profiling option in ProfileServlet #281

Merged
merged 2 commits into from
Apr 19, 2023
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
@@ -1,4 +1,4 @@
/**
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand Down Expand Up @@ -47,6 +47,7 @@
* // -i interval sampling interval in nanoseconds (long)
* // -j jstackdepth maximum Java stack depth (integer)
* // -b bufsize frame buffer size (long)
* // -m method fully qualified method name: 'ClassName.methodName'
* // -t profile different threads separately
* // -s simple class names instead of FQN
* // -o fmt[,fmt...] output format: summary|traces|flat|collapsed|svg|tree|jfr
Expand Down Expand Up @@ -196,18 +197,28 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
final Integer height = getInteger(request, "height", null);
final Double minwidth = getMinWidth(request);
final boolean reverse = request.getParameterMap().containsKey("reverse");
final String method = request.getParameter("method");

if (request.getParameter("event") != null && method != null) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
setResponseHeader(response);
response.getWriter().write("Event and method aren't allowed to be both used in the same request.");
return;
}

if (process == null || !process.isAlive()) {
try {
int lockTimeoutSecs = 3;
if (profilerLock.tryLock(lockTimeoutSecs, TimeUnit.SECONDS)) {
try {
File outputFile = new File(OUTPUT_DIR,
"async-prof-pid-" + pid + "-" + event.name().toLowerCase() + "-" + ID_GEN.incrementAndGet() + "."
"async-prof-pid-" + pid + "-"
+ (method == null ? event.name().toLowerCase() : method) + "-" + ID_GEN.incrementAndGet() + "."
+ output.name().toLowerCase());
List<String> cmd = new ArrayList<>();
cmd.add(asyncProfilerHome + PROFILER_SCRIPT);
cmd.add("-e");
cmd.add(event.getInternalName());
cmd.add(method == null ? event.getInternalName() : method);
cmd.add("-d");
cmd.add("" + duration);
cmd.add("-o");
Expand Down