diff options
author | Robert Newson <rnewson@apache.org> | 2023-03-28 16:33:02 +0100 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2023-03-28 16:33:02 +0100 |
commit | 6c213e58723f03ac2a34ac082cf286f2323da56c (patch) | |
tree | d04bafadc207d5bc02b4b1fb332c37e43ec4aace | |
parent | 91d0e20ac3f8002db19eb8d3109df2785739be69 (diff) | |
download | couchdb-6c213e58723f03ac2a34ac082cf286f2323da56c.tar.gz |
increment row/read stats
-rw-r--r-- | src/nouveau/src/nouveau_httpd.erl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nouveau/src/nouveau_httpd.erl b/src/nouveau/src/nouveau_httpd.erl index c5043c3ab..d8a309b7e 100644 --- a/src/nouveau/src/nouveau_httpd.erl +++ b/src/nouveau/src/nouveau_httpd.erl @@ -91,6 +91,8 @@ handle_search_req(#httpd{} = Req, DbName, DDoc, IndexName, QueryArgs) -> <<"counts">> => maps:get(<<"counts">>, SearchResults, null), <<"ranges">> => maps:get(<<"ranges">>, SearchResults, null) }, + RowCount = length(maps:get(<<"rows">>, RespBody)), + incr_stats(RowCount, IncludeDocs), send_json(Req, 200, RespBody); {error, Reason} -> send_error(Req, Reason) @@ -107,6 +109,12 @@ include_docs(DbName, Hits, true) -> {ok, Docs} = nouveau_fabric:get_json_docs(DbName, Ids), lists:zipwith(fun(Hit, Doc) -> Hit#{<<"doc">> => Doc} end, Hits, Docs). +incr_stats(RowCount, false) -> + chttpd_stats:incr_rows(RowCount); +incr_stats(RowCount, true) -> + chttpd_stats:incr_reads(RowCount), + incr_stats(RowCount, false). + parse_bool_param(_, Val) when is_boolean(Val) -> Val; parse_bool_param(_, "true") -> |