diff --git a/nano/lib/stats.cpp b/nano/lib/stats.cpp index 222603434d..308668e65d 100644 --- a/nano/lib/stats.cpp +++ b/nano/lib/stats.cpp @@ -432,7 +432,7 @@ void nano::stats::update (key key_a, uint64_t value) // Counters auto old (entry->counter.get_value ()); entry->counter.add (value, has_sampling ()); // Only update timestamp when sampling is enabled as this has a performance impact - entry->count_observers.notify (old, entry->counter.get_value ()); + if (has_interval_counter () || has_sampling ()) { auto now = std::chrono::steady_clock::now (); // Only sample clock if necessary as this impacts node performance due to frequent usage @@ -461,12 +461,6 @@ void nano::stats::update (key key_a, uint64_t value) entry->samples.push_back (entry->sample_current); entry->sample_current.set_value (0); - if (!entry->sample_observers.empty ()) - { - auto snapshot (entry->samples); - entry->sample_observers.notify (snapshot); - } - // Log sink duration = now - log_last_sample_writeout; if (config.log_interval_samples > 0 && duration.count () > config.log_interval_samples) diff --git a/nano/lib/stats.hpp b/nano/lib/stats.hpp index 5d8a108942..5afee0267e 100644 --- a/nano/lib/stats.hpp +++ b/nano/lib/stats.hpp @@ -143,12 +143,6 @@ class stat_entry final /** Optional histogram for this entry */ std::unique_ptr histogram; - - /** Zero or more observers for samples. Called at the end of the sample interval. */ - nano::observer_set &> sample_observers; - - /** Observers for count. Called on each update. */ - nano::observer_set count_observers; }; /** Log sink interface */ @@ -316,32 +310,6 @@ class stats final */ void add (stat::type type, stat::detail detail, stat::dir dir, uint64_t value); - /** - * Add a sampling observer for a given counter. - * The observer receives a snapshot of the current sampling. Accessing the sample buffer is thus thread safe. - * To avoid recursion, the observer callback must only use the received data point snapshop, not query the stat object. - * @param observer The observer receives a snapshot of the current samples. - */ - void observe_sample (stat::type type, stat::detail detail, stat::dir dir, std::function &)> observer) - { - get_entry (key{ type, detail, dir })->sample_observers.add (observer); - } - - void observe_sample (stat::type type, stat::dir dir, std::function &)> observer) - { - observe_sample (type, stat::detail::all, dir, observer); - } - - /** - * Add count observer for a given type, detail and direction combination. The observer receives old and new value. - * To avoid recursion, the observer callback must only use the received counts, not query the stat object. - * @param observer The observer receives the old and the new count. - */ - void observe_count (stat::type type, stat::detail detail, stat::dir dir, std::function observer) - { - get_entry (key{ type, detail, dir })->count_observers.add (observer); - } - /** Returns a potentially empty list of the last N samples, where N is determined by the 'capacity' configuration */ boost::circular_buffer * samples (stat::type type, stat::detail detail, stat::dir dir) {