Skip to content

Commit 231a4c1

Browse files
author
Dmitriy Fingerman
committed
TEZ-4487: Add class name profiling option in ProfileServlet
1 parent be99489 commit 231a4c1

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

tez-common/src/main/java/org/apache/tez/common/web/ProfileServlet.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* Licensed to the Apache Software Foundation (ASF) under one
33
* or more contributor license agreements. See the NOTICE file
44
* distributed with this work for additional information
@@ -47,6 +47,7 @@
4747
* // -i interval sampling interval in nanoseconds (long)
4848
* // -j jstackdepth maximum Java stack depth (integer)
4949
* // -b bufsize frame buffer size (long)
50+
* // -m method fully qualified method name: 'ClassName.methodName'
5051
* // -t profile different threads separately
5152
* // -s simple class names instead of FQN
5253
* // -o fmt[,fmt...] output format: summary|traces|flat|collapsed|svg|tree|jfr
@@ -196,18 +197,28 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
196197
final Integer height = getInteger(request, "height", null);
197198
final Double minwidth = getMinWidth(request);
198199
final boolean reverse = request.getParameterMap().containsKey("reverse");
200+
final String method = request.getParameter("method");
201+
202+
if (request.getParameter("event") != null && method != null) {
203+
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
204+
setResponseHeader(response);
205+
response.getWriter().write("Event and method aren't allowed to be both used in the same request.");
206+
return;
207+
}
208+
199209
if (process == null || !process.isAlive()) {
200210
try {
201211
int lockTimeoutSecs = 3;
202212
if (profilerLock.tryLock(lockTimeoutSecs, TimeUnit.SECONDS)) {
203213
try {
204214
File outputFile = new File(OUTPUT_DIR,
205-
"async-prof-pid-" + pid + "-" + event.name().toLowerCase() + "-" + ID_GEN.incrementAndGet() + "."
215+
"async-prof-pid-" + pid + "-"
216+
+ (method == null ? event.name().toLowerCase() : method) + "-" + ID_GEN.incrementAndGet() + "."
206217
+ output.name().toLowerCase());
207218
List<String> cmd = new ArrayList<>();
208219
cmd.add(asyncProfilerHome + PROFILER_SCRIPT);
209220
cmd.add("-e");
210-
cmd.add(event.getInternalName());
221+
cmd.add(method == null ? event.getInternalName() : method);
211222
cmd.add("-d");
212223
cmd.add("" + duration);
213224
cmd.add("-o");

0 commit comments

Comments
 (0)