Skip to content

Conversation

@lvrach
Copy link
Member

@lvrach lvrach commented Nov 8, 2023

Description

WARNING: Requires rudderlabs/rudder-go-kit#210 to be merged first

Motivation

Gather statistics about delayed events. Events that are being delivered - usually due to retries - many days after their initial creation.

The intention is to gather stats, that can be used for decision making and further help investigation of deduplicate records.

Implementation

I created a separate delayed package for encapsulation and testability.

sourceObserver interface provides a generic way to inspect events on the source level.

Linear Ticket

Completes PIPE-516

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@lvrach lvrach marked this pull request as ready for review November 9, 2023 17:42
@lvrach lvrach force-pushed the chore.capture-delayed-events branch from e2448ee to 9513fd6 Compare November 9, 2023 18:15
@codecov
Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (ea455ca) 72.44% compared to head (d88691b) 72.49%.

Files Patch % Lines
processor/processor.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4104      +/-   ##
==========================================
+ Coverage   72.44%   72.49%   +0.04%     
==========================================
  Files         382      383       +1     
  Lines       55420    55476      +56     
==========================================
+ Hits        40149    40216      +67     
+ Misses      12940    12931       -9     
+ Partials     2331     2329       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +1619 to +1626
source, err := proc.getSourceBySourceID(string(sourceID))
if err != nil {
continue
}

for _, obs := range proc.sourceObservers {
obs.ObserveSourceEvents(source, events)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: alternative with less lines

Suggested change
source, err := proc.getSourceBySourceID(string(sourceID))
if err != nil {
continue
}
for _, obs := range proc.sourceObservers {
obs.ObserveSourceEvents(source, events)
}
if source, err := proc.getSourceBySourceID(string(sourceID)); err == nil {
for _, obs := range proc.sourceObservers {
obs.ObserveSourceEvents(source, events)
}
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the usage of if ...; err == nil less readable. I am in favor of aligning the happy path to the left. https://medium.com/@matryer/line-of-sight-in-code-186dd7cdea88

Comment on lines 39 to 50
sdkContext, err := misc.NestedMapLookup(event.Message, "context", "library")
if err == nil {
m, ok := sdkContext.(map[string]interface{})
if ok {
sdkLibVersion, _ := m["version"].(string)
sdkLibName, _ := m["name"].(string)

if sdkLibName != "" || sdkLibVersion != "" {
sdkVersion = fmt.Sprintf("%s/%s", sdkLibName, sdkLibVersion)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sdkContext, err := misc.NestedMapLookup(event.Message, "context", "library")
if err == nil {
m, ok := sdkContext.(map[string]interface{})
if ok {
sdkLibVersion, _ := m["version"].(string)
sdkLibName, _ := m["name"].(string)
if sdkLibName != "" || sdkLibVersion != "" {
sdkVersion = fmt.Sprintf("%s/%s", sdkLibName, sdkLibVersion)
}
}
}
if sdkContext, err := misc.NestedMapLookup(event.Message, "context", "library"); err == nil {
if m, ok := sdkContext.(map[string]interface{}); ok {
sdkVersion = strings.Join([]string{m["version"].(string), m["name"].(string)}, "/")
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants