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

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


The following commit(s) were added to refs/heads/master by this push:
     new fd6b290c889 [feat](FE) add rest api to get last profile (#38268)
fd6b290c889 is described below

commit fd6b290c889b4b60f2cda86672ddd37afb7ad0bc
Author: minghong <engle...@gmail.com>
AuthorDate: Fri Jul 26 09:21:41 2024 +0800

    [feat](FE) add rest api to get last profile (#38268)
    
    ## Proposed changes
    if you want to get the profile of the query just executed, it not
    neccessary to find the query_id now.
    this is useful to get profiles in shell script, for example, we want to
    get all profiles of tpcds queries (103 query profile) in a shell script.
    
    before:
    curl
    
http://root:@127.0.0.1:8030/api/profile/text?query_id=990cc3b19e464e03-a3af05a997eb4091
    > profile
    after:
    curl http://root:@127.0.0.1:8030/api/profile/text > profilex
    
    Issue Number: close #xxx
    
    <!--Describe your changes.-->
---
 .../src/main/java/org/apache/doris/common/util/ProfileManager.java    | 4 ++++
 .../src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java     | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
index 9c3490b4c96..4c1d6b30859 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
@@ -447,6 +447,10 @@ public class ProfileManager {
         }
     }
 
+    public String getLastQueryId() {
+        return queryIdDeque.getLast();
+    }
+
     public String getProfileBrief(String queryID) {
         readLock.lock();
         try {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java
index 4dcac417d57..5c1bc8213a2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java
@@ -69,7 +69,7 @@ public class ProfileAction extends RestBaseController {
 
         String queryId = request.getParameter("query_id");
         if (Strings.isNullOrEmpty(queryId)) {
-            return "Missing query_id";
+            queryId = ProfileManager.getInstance().getLastQueryId();
         }
 
         String queryProfileStr = 
ProfileManager.getInstance().getProfile(queryId);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to