@@ -117,15 +117,15 @@ def filter(tag, time, record)
117117
118118 # Ruby hashes are ordered by insertion.
119119 # Deleting and inserting moves the item to the end of the hash (most recently used)
120- counter = @counters [ group ] = @counters . delete ( group ) || Group . new ( 0 , now , 0 , 0 , now , nil , @group_bucket_limit )
120+ counter = @counters [ group ] = @counters . delete ( group ) || Group . new ( 0 , now , 0 , 0 , now , nil , 0 )
121121
122122 counter . rate_count += 1
123123 since_last_rate_reset = now - counter . rate_last_reset
124124 if since_last_rate_reset >= 1
125125 # compute and store rate/s at most every second
126126 counter . aprox_rate = ( counter . rate_count / since_last_rate_reset ) . round ( )
127127 counter . rate_count = 0
128- counter . rate_count_last = @group_bucket_limit
128+ counter . rate_count_last = 0
129129 counter . rate_last_reset = now
130130 end
131131
@@ -186,8 +186,8 @@ def log_rate_limit_exceeded(now, group, counter)
186186 groupped_label = @group_key_symbols . zip ( group ) . to_h
187187 metric = @metrics [ :throttle_rate_limit_exceeded ]
188188 log . debug ( "current rate" , counter . rate_count , "current metric" , metric . get ( labels : @base_labels . merge ( groupped_label ) ) )
189- metric . increment ( by : counter . rate_count - counter . rate_count_last , labels : @base_labels . merge ( groupped_label ) )
190- counter . rate_count_last = counter . rate_count
189+ metric . increment ( by : counter . rate_count - counter . rate_count_last - @group_bucket_limit , labels : @base_labels . merge ( groupped_label ) )
190+ counter . rate_count_last = counter . rate_count - @group_bucket_limit
191191 end
192192
193193 emit = counter . last_warning == nil ? true \
0 commit comments