Skip to content

Commit 29d1187

Browse files
authored
Merge pull request syslog-ng#5217 from HofiOne/Fix-eps-counter-inconsistencies
stats: try to provide more consistent aggregate values
2 parents 65fce25 + c74e014 commit 29d1187

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

lib/stats/aggregator/stats-aggregator.c

+18
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,24 @@ stats_aggregator_stop(StatsAggregator *self)
129129
stats_aggregator_unregister(self);
130130
}
131131

132+
void
133+
stats_aggregator_reset(StatsAggregator *self)
134+
{
135+
main_loop_assert_main_thread();
136+
137+
if (self && self->reset)
138+
self->reset(self);
139+
140+
/* NOTE: This will align all the timers to the next period boundary that leads to
141+
* - a consistent update time for all the aggregators
142+
* - a consistent time period for the calculation of the aggregated value
143+
* The latter is important because the users and our tests expect the aggregated value to be
144+
* calculated for the same time period, and expect similar values for the same time period.
145+
*/
146+
_stop_timer(self);
147+
_restart_timer(self);
148+
}
149+
132150
static gboolean
133151
_is_orphaned(StatsAggregator *self)
134152
{

lib/stats/aggregator/stats-aggregator.h

-7
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ stats_aggregator_aggregate(StatsAggregator *self)
6363
self->aggregate(self);
6464
}
6565

66-
static inline void
67-
stats_aggregator_reset(StatsAggregator *self)
68-
{
69-
if (self && self->reset)
70-
self->reset(self);
71-
}
72-
7366
static inline gboolean
7467
stats_aggregator_is_orphaned(StatsAggregator *self)
7568
{

0 commit comments

Comments
 (0)