-
Notifications
You must be signed in to change notification settings - Fork 892
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
GODRIVER-3095 Add moving STD to RTT Stats #1845
Conversation
# This is the 1st commit message: test # This is the commit message mongodb#2: test2
API Change ReportNo changes found! |
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.
LGTM 🔧
internal/stats/stats.go
Outdated
"time" | ||
) | ||
|
||
func StandardDeviationList[T time.Duration | float64](l *list.List) float64 { |
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.
There's currently no use case for this function to be outside of the x/mongo/driver/topology
package, so it should be moved there and un-exported. There's also currently no use case for passing a list of float64
, so the function can assume the list contains time.Duration
and doesn't need to be generic.
Those changes allow us to avoid passing list.List
between package APIs, which can lead to runtime panics since list.List
doesn't provide compile-time type safety (i.e. Element.Value
is type any
). When we need a more flexible standard deviation function, we can move it to a shared package and figure out a type-safe way to pass values then.
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.
It's notable that if we don't keep stats functions in a standardized place, duplication is likely.
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 possible, but that's easy to fix if it happens. Using a *list.List
to pass data of a particular type is prone to runtime panics because of the lack of type safety, so if we were going to generalize the implementation, I'd recommend changing the data type. Keeping it private for now means we don't have to figure that out yet.
BTW I apologize for the conflicting feedback that @prestonvasquez and I gave concerning where to put the stddev implementation.
9873990
to
0141ce4
Compare
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.
Looks good! 👍
GODRIVER-3095
Summary
Background & Motivation