You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2024/02/17 01:03:05 UTC

(couchdb) branch add-dbname-to-mango-exec-stats updated: Don't output dbname in exec stats http response

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

chewbranca pushed a commit to branch add-dbname-to-mango-exec-stats
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/add-dbname-to-mango-exec-stats by this push:
     new 8f611bbfd Don't output dbname in exec stats http response
8f611bbfd is described below

commit 8f611bbfd932fab7ace9b9ce62880bf4a80f308a
Author: Russell Branca <ch...@apache.org>
AuthorDate: Fri Feb 16 17:02:49 2024 -0800

    Don't output dbname in exec stats http response
---
 src/mango/src/mango_execution_stats.erl | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/mango/src/mango_execution_stats.erl b/src/mango/src/mango_execution_stats.erl
index 11336132d..1e9c51655 100644
--- a/src/mango/src/mango_execution_stats.erl
+++ b/src/mango/src/mango_execution_stats.erl
@@ -13,7 +13,7 @@
 -module(mango_execution_stats).
 
 -export([
-    to_json/1,
+    to_json/1, to_json/2,
     to_map/1,
     incr_keys_examined/1,
     incr_keys_examined/2,
@@ -37,13 +37,23 @@
 -define(SHARD_STATS_KEY, mango_shard_execution_stats).
 
 to_json(Stats) ->
+    to_json(Stats, true).
+
+
+to_json(Stats, IncludeDbName) ->
+    Base = case IncludeDbName of
+        true ->
+            [{dbname, Stats#execution_stats.dbname}];
+        false ->
+            []
+    end,
     {[
         {total_keys_examined, Stats#execution_stats.totalKeysExamined},
         {total_docs_examined, Stats#execution_stats.totalDocsExamined},
         {total_quorum_docs_examined, Stats#execution_stats.totalQuorumDocsExamined},
         {results_returned, Stats#execution_stats.resultsReturned},
-        {execution_time_ms, Stats#execution_stats.executionTimeMs},
-        {dbname, Stats#execution_stats.dbname}
+        {execution_time_ms, Stats#execution_stats.executionTimeMs}
+        | Base
     ]}.
 
 to_map(Stats) ->
@@ -106,7 +116,7 @@ maybe_add_stats(Opts, UserFun, Stats0, UserAcc) ->
     FinalAcc =
         case couch_util:get_value(execution_stats, Opts) of
             true ->
-                JSONValue = to_json(Stats1),
+                JSONValue = to_json(Stats1, false),
                 Arg = {add_key, execution_stats, JSONValue},
                 {_Go, FinalUserAcc} = UserFun(Arg, UserAcc),
                 FinalUserAcc;