You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by ab...@apache.org on 2023/04/19 14:58:41 UTC

[tez] branch master updated: TEZ-4487: Add class name profiling option in ProfileServlet (#281) (Dmitriy Fingerman reviewed by Laszlo Bodor)

This is an automated email from the ASF dual-hosted git repository.

abstractdog pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tez.git


The following commit(s) were added to refs/heads/master by this push:
     new 2fe3c461d TEZ-4487: Add class name profiling option in ProfileServlet (#281) (Dmitriy Fingerman reviewed by Laszlo Bodor)
2fe3c461d is described below

commit 2fe3c461d0731ab21ef4640c6bb4fae2bb561253
Author: Dmitriy Fingerman <dm...@gmail.com>
AuthorDate: Wed Apr 19 10:58:33 2023 -0400

    TEZ-4487: Add class name profiling option in ProfileServlet (#281) (Dmitriy Fingerman reviewed by Laszlo Bodor)
---
 .../java/org/apache/tez/common/web/ProfileServlet.java  | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tez-common/src/main/java/org/apache/tez/common/web/ProfileServlet.java b/tez-common/src/main/java/org/apache/tez/common/web/ProfileServlet.java
index 1cdddfbf9..b2b9266da 100644
--- a/tez-common/src/main/java/org/apache/tez/common/web/ProfileServlet.java
+++ b/tez-common/src/main/java/org/apache/tez/common/web/ProfileServlet.java
@@ -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
@@ -47,6 +47,7 @@ import java.util.concurrent.locks.ReentrantLock;
  * //  -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
@@ -196,18 +197,28 @@ public class ProfileServlet extends HttpServlet {
     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");