fix(router): check outer event key in failuresMetric guard to prevent inner-map wipe - #7265
Open
harsh4vardhan wants to merge 1 commit into
Open
Conversation
…inner map
The guard condition that initializes the inner map of failuresMetric
checks whether the error-string key exists in the inner map rather
than whether the outer event-type key exists:
if _, ok := rt.telemetry.failuresMetric[event][errorStr]; !ok {
rt.telemetry.failuresMetric[event] = make(map[string]int)
}
When a destination produces a second distinct error string the inner
map lookup returns false (the new string is not there yet), triggering
make() and wiping the entire inner map. Any previously accumulated
counts for that event type are lost. In a busy destination this
resets on every new error variant within a reporting window.
Fix: check the outer event-type key instead so the inner map is only
initialised once per event type.
Fixes rudderlabs#7260
Signed-off-by: harsh4vardhan <hvardhan609@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #7260.
The guard that initialises
failuresMetric's inner map checks whetherthe error string exists in the inner map, not whether the event
type key exists in the outer map:
Whenever a destination produces a second distinct error string within
one reporting window, the inner-map lookup returns
false(the newstring isn't there yet),
make()fires, and every count accumulatedso far for that event type is lost. In a busy destination this resets
on every new error variant.
Fix
Check the outer event-type key so the inner map is initialised once
per event type and never overwritten:
harsh4vardhan