nickva commented on code in PR #4672: URL: https://github.com/apache/couchdb/pull/4672#discussion_r1266209748
########## src/couch_stats/src/couch_stats_server.erl: ########## @@ -0,0 +1,246 @@ +% 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. + +% couch_stats_server is in charge of: +% - Initial metric loading from application stats descriptions. +% - Recycling(resetting to 0) stale histogram counters. +% - Checking and reloading if stats descriptions change. +% - Checking and reloading if histogram window size config value changes. +% + +-module(couch_stats_server). + +-behaviour(gen_server). + +-export([ + reload/0 +]). + +-export([ + start_link/0, + init/1, + handle_call/3, + handle_cast/2, + handle_info/2 +]). + +-define(RELOAD_INTERVAL_SEC, 600). + +-record(st, { + hist_interval, + histograms, + hist_tref, + reload_tref +}). + +reload() -> + gen_server:call(?MODULE, reload). + +start_link() -> + gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). + +init([]) -> + St = #st{ + hist_interval = config:get("stats", "interval"), + hist_tref = erlang:send_after(hist_msec(), self(), clean), Review Comment: Yes! Much better. I started with the previous stats aggregate server which did aggregation so I was going to add histogram cleaning. But in the final version we only do histogram cleaning, so I'll use your suggestions. -- 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]
