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

[couchdb] 01/01: track active search requests

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

rnewson pushed a commit to branch dreyfus_active_searhes
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit da142e0b35fb78cfb878230a7e0c2bdca180fc7d
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Apr 4 20:54:30 2023 +0100

    track active search requests
---
 src/dreyfus/priv/stats_descriptions.cfg | 5 +++++
 src/dreyfus/src/dreyfus_rpc.erl         | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/dreyfus/priv/stats_descriptions.cfg b/src/dreyfus/priv/stats_descriptions.cfg
index 7f93ee26a..ad5277f09 100644
--- a/src/dreyfus/priv/stats_descriptions.cfg
+++ b/src/dreyfus/priv/stats_descriptions.cfg
@@ -63,3 +63,8 @@
     {type, counter},
     {desc, <<"Search IO directly triggered by client requests">>}
 ]}.
+
+[dreyfus, active_searches], [
+    {type, counter},
+    {desc, <<"number of active search requests">>}
+]}.
\ No newline at end of file
diff --git a/src/dreyfus/src/dreyfus_rpc.erl b/src/dreyfus/src/dreyfus_rpc.erl
index 2ebc5ffe5..bfc4ec9f2 100644
--- a/src/dreyfus/src/dreyfus_rpc.erl
+++ b/src/dreyfus/src/dreyfus_rpc.erl
@@ -25,7 +25,12 @@
 
 search(DbName, DDoc, IndexName, QueryArgs) ->
     MFA = {?MODULE, call, [search, DbName, DDoc, IndexName, QueryArgs]},
-    dreyfus_util:time([rpc, search], MFA).
+    couch_stats:increment_counter([dreyfus, active_searches]),
+    try
+        dreyfus_util:time([rpc, search], MFA)
+    after
+        couch_stats:decrement_counter([dreyfus, active_searches]),
+    end.
 
 group1(DbName, DDoc, IndexName, QueryArgs) ->
     MFA = {?MODULE, call, [group1, DbName, DDoc, IndexName, QueryArgs]},