-
Notifications
You must be signed in to change notification settings - Fork 193
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
Fix time based average stats #442
Conversation
Pgbouncer makes it look easy: https://github.com/pgbouncer/pgbouncer/blob/master/src/stats.c#L67 :) |
pub avg_xact_time: Arc<AtomicU64>, | ||
pub avg_xact_count: Arc<AtomicU64>, | ||
pub avg_wait_time: Arc<AtomicU64>, | ||
total: AddressStatFields, |
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.
Nice refactor
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 to me (it's merged either way).
@magec Still wanted to get your eyes on this one and wanted to make sure you update and validate on your end. Thanks! |
Some stat averages were being calculated incorrectly for example, average query time (latency) was being calculated by dividing the total query time by our stat period (15 seconds). Instead we should be dividing by the number of queries we observed in that stat period.
Also, I've removed the tracking of old stat total, to just tracking the current totals for the given stat period, and after that stat period completes the current totals are re-zeroed (similar to how pgbouncer does it)