|
1 | | -/** |
| 1 | + /** |
2 | 2 | * Licensed to the Apache Software Foundation (ASF) under one |
3 | 3 | * or more contributor license agreements. See the NOTICE file |
4 | 4 | * distributed with this work for additional information |
|
47 | 47 | * // -i interval sampling interval in nanoseconds (long) |
48 | 48 | * // -j jstackdepth maximum Java stack depth (integer) |
49 | 49 | * // -b bufsize frame buffer size (long) |
| 50 | + * // -m method fully qualified method name: 'ClassName.methodName' |
50 | 51 | * // -t profile different threads separately |
51 | 52 | * // -s simple class names instead of FQN |
52 | 53 | * // -o fmt[,fmt...] output format: summary|traces|flat|collapsed|svg|tree|jfr |
@@ -196,18 +197,28 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro |
196 | 197 | final Integer height = getInteger(request, "height", null); |
197 | 198 | final Double minwidth = getMinWidth(request); |
198 | 199 | 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 | + |
199 | 209 | if (process == null || !process.isAlive()) { |
200 | 210 | try { |
201 | 211 | int lockTimeoutSecs = 3; |
202 | 212 | if (profilerLock.tryLock(lockTimeoutSecs, TimeUnit.SECONDS)) { |
203 | 213 | try { |
204 | 214 | 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() + "." |
206 | 217 | + output.name().toLowerCase()); |
207 | 218 | List<String> cmd = new ArrayList<>(); |
208 | 219 | cmd.add(asyncProfilerHome + PROFILER_SCRIPT); |
209 | 220 | cmd.add("-e"); |
210 | | - cmd.add(event.getInternalName()); |
| 221 | + cmd.add(method == null ? event.getInternalName() : method); |
211 | 222 | cmd.add("-d"); |
212 | 223 | cmd.add("" + duration); |
213 | 224 | cmd.add("-o"); |
|
0 commit comments