-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove caching objects to prevent leak #2966
Conversation
excludeTags: configExcludeTags(cfg), | ||
} | ||
} | ||
|
||
func (m *OtelMetricHandler) Event(ctx context.Context, e *event.Event) context.Context { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide some context on why the pointer is not necessary here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing is changing on the receiver and does not need to be a pointer.
func (m *OtelMetricHandler) getRecordFunc(em event.Metric) recordFunc { | ||
m.mu.Lock() | ||
defer m.mu.Unlock() | ||
if f, ok := m.recordFuncs[em]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so event.Metric is unbounded?
And instead of caching recordFuns, we create a new one every time? Will it impact latency or gc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is the GC is now collecting what was leaking before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand the unbounded, the objects needed in the function are captured, em is only needed for logging before returning recording function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the events coming as parameters to the Event
function are pooled, it is not unbounded.
What changed?
Remove caching recording functions
Why?
Fixing memory leak
How did you test it?
locally, pprof heap dump with running canary
Potential risks
None
Is hotfix candidate?
No