pgj commented on code in PR #4812:
URL: https://github.com/apache/couchdb/pull/4812#discussion_r1413110894


##########
src/rexi/src/rexi.erl:
##########
@@ -328,3 +336,23 @@ drain_acks(Count) ->
     after 0 ->
         {ok, Count}
     end.
+
+get_delta() ->
+    {delta, couch_stats_resource_tracker:make_delta()}.
+
+maybe_add_delta(T) ->
+    case couch_stats_resource_tracker:is_enabled() of
+        false ->
+            T;
+        true ->
+            add_delta(T, get_delta())
+    end.
+
+add_delta({A}, Delta) -> {A, Delta};

Review Comment:
   Would not it be better to make it the inverse of `rexi_utils:get_delta/1`?  
(And place this function in `rexi_utils` as well?)  That is, the `Delta` 
argument would not be expected to be like `{delta, D}`, but only `D` and the 
`delta` tag would be automatically applied on that:
   
   ```erlang
   add_delta(T, Delta) when 0 < erlang:size(T), erlang:size(T) < 8 ->
       erlang:insert_element(erlang:size(T) + 1, T, {delta, Delta});
   add_delta(T, _Delta) -> T.
   ```
   
   This way the following property would hold:
   
   ```erlang
   ?FORALL(T, tuple(),
       ?FORALL(D, any(),
           ?IMPLIES(0 < erlang:size(T) andalso erlang:size(T) < 8,
               extract_delta(add_delta(T, D)) == {T, D}))).
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to