-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add sql connection pool metrics #8071
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
Conversation
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.
Apologies for the late review.
Head branch was pushed to by a user without write access
started int32 | ||
stopped int32 |
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 use atomic bools here: https://pkg.go.dev/sync/atomic#Bool
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.
But also wondering why this would be started multiple times since it's only instantiated in the handle constructor and immediately started there.
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.
I switched it to atomic.Bool
in 921be96
Yeah, Start
will probably only be called once, but Stop
might be called multiple times, which I'm not sure about. Just keep it symmetric with the stop.
Before the guard check, the Go race detector complains about a race condition in WaitGroup. I'm adding these to resolve the race condition
if atomic.LoadInt32(&r.stopped) == 1 { | ||
return | ||
} |
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.
A but redundant IMHO but no objection to keep this.
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.
sure enough. I'm keeping this at the moment
Co-authored-by: Roey Berman <[email protected]>
Co-authored-by: Roey Berman <[email protected]>
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.
I've already approved this, at this point it's nitpicking. Feel free to address the last couple of comments if you feel like it. Otherwise, I can merge as is.
reporter.started.Store(false) | ||
reporter.stopped.Store(false) |
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.
No need, the zero value is false.
if !r.started.CompareAndSwap(false, true) { | ||
return | ||
} |
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.
Still don't feel like we need this but 🤷
r.wg.Add(1) | ||
go r.run() |
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.
r.wg.Add(1) | |
go r.run() | |
r.wg.Go(r.run) |
} | ||
|
||
func (r *DBMetricsReporter) run() { | ||
defer r.wg.Done() |
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.
No need if you use wg.Go
.
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.
oh nice. I just know about this method. Unfortunately, it is only available with go 1.25. Temporal is using go 1.24 instead
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.
That's not true anymore
Line 3 in 16b1e29
go 1.25.0 |
the CI is failing. Do I need to rebase or checking anything @bergundy . Look like some docker service is missing |
I merged main into the PR branch, lets see if that fixes CI. |
All good. It is great working with you |
I'm merging, would have liked some of the small comments to have been addressed but there's nothing critical blocking this right now. Thanks for the contribution. |
|
||
func (r *DBMetricsReporter) report() { | ||
db := r.handle.db.Load() | ||
if db == nil { |
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.
@bergundy should stats go to zero if this occurs?
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.
Hmm... this is just an edge case. I would say it's undefined. Most of the time the gauge will stay at the last value for the host.
What changed?
Adding sql connection pool metrics from stdlib
Stats
Why?
Expose more metrics for config fine tuning
How did you test it?