iilyak-ibm commented on code in PR #5602: URL: https://github.com/apache/couchdb/pull/5602#discussion_r2337332822
########## src/couch_srt/src/couch_srt_util.erl: ########## @@ -0,0 +1,244 @@ +% Licensed under the Apache License, Version 2.0 (the "License"); you may not +% use this file except in compliance with the License. You may obtain a copy of +% the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +% License for the specific language governing permissions and limitations under +% the License. + +-module(couch_srt_util). + +-export([ + is_enabled/0, + is_enabled_init_p/0, + is_enabled_reporting/0, + is_enabled_rpc_reporting/0, + get_pid_ref/0, + get_pid_ref/1, + set_pid_ref/1, + tnow/0, + tutc/0, + tutc/1 +]). + +%% Delta API +-export([ + add_delta/2, + extract_delta/1, + get_delta/1, + get_delta_a/0, + get_updated_at/0, + maybe_add_delta/1, + maybe_add_delta/2, + make_delta/1, + make_dt/2, + make_dt/3, + rctx_delta/2, + put_delta_a/1, + put_updated_at/1 +]). + +-include_lib("couch_srt.hrl"). + +-ifdef(TEST). +-spec is_enabled() -> boolean(). +is_enabled() -> + %% randomly enable CSRT during testing to handle unexpected failures + case config:get_boolean(?CSRT, "randomize_testing", true) of + true -> + rand:uniform(100) > 80; + false -> + config:get_boolean(?CSRT, "enable", true) + end. +-else. +-spec is_enabled() -> boolean(). +is_enabled() -> + config:get_boolean(?CSRT, "enable", false). +-endif. + +-spec is_enabled_init_p() -> boolean(). +is_enabled_init_p() -> + config:get_boolean(?CSRT, "enable_init_p", false). + +%% Toggle to disable all reporting +-spec is_enabled_reporting() -> boolean(). +is_enabled_reporting() -> + config:get_boolean(?CSRT, "enable_reporting", false). + +%% Toggle to disable all reporting from #rpc_worker{} types, eg only log +%% #coordinator{} types. This is a bit of a kludge that would be better served +%% by a dynamic match spec generator, but this provides a know for disabling +%% any rpc worker logs, even if they hit the normal logging Threshold's. +-spec is_enabled_rpc_reporting() -> boolean(). +is_enabled_rpc_reporting() -> + config:get_boolean(?CSRT, "enable_rpc_reporting", false). + +%% Monotnonic time now in native format using time forward only event tracking Review Comment: addressed in 07754362a55880eab509fc322a93fe144a442bad -- 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-unsubscr...@couchdb.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org