You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/07/19 19:11:28 UTC

[GitHub] [couchdb] nickva commented on a diff in pull request #3888: Fix stats endpoint

nickva commented on code in PR #3888:
URL: https://github.com/apache/couchdb/pull/3888#discussion_r924870628


##########
src/chttpd/src/chttpd_node.erl:
##########
@@ -358,8 +358,13 @@ format_pid_stats(Mailboxes) ->
 get_distribution_stats() ->
     lists:map(
         fun({Node, Socket}) ->
-            {ok, Stats} = inet:getstat(Socket),
-            {Node, {Stats}}
+            try inet:getstat(Socket) of
+                {ok, Stats} ->
+                    {Node, {Stats}}
+            catch
+                _:_ ->
+                    {Node, {}}

Review Comment:
   This will crash as `{}` is not valid json. So at least it would have to be `{[]}`
   
   Another thing to consider if anything interpreting the results actually expects all those keys in the json object and cannot handle an empty object. Then it could make sense to emit:
   
   ```
   {[
        {recv_oct,0},
        {recv_cnt,0},
        {recv_max,0},
        {recv_avg,0},
        {recv_dvi,0},
        {send_oct,0},
        {send_cnt,0},
        {send_max,0},
        {send_avg,0},
        {send_pend,0}
   ]}
   ```
   
   We'd have to see if we ever documented the response type as having those keys or not. If not an empty json object is probably ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org