Skip to content

Export postgres and redis query timing metrics as histograms - #638

Merged
ajayyy merged 4 commits into
ajayyy:masterfrom
mini-bomba:histogram-metrics
Sep 17, 2026
Merged

ajayyy merged 4 commits into
ajayyy:masterfrom
mini-bomba:histogram-metrics

Conversation

@mini-bomba

@mini-bomba mini-bomba commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
  • I agree to license my contribution under AGPL-3.0-only with my contribution automatically being licensed under LGPL-3.0 additionally after 6 months

currently all we have are rolling averages, which aren't really precise

this PR exports the timings as histograms, which should allow us to see exactly how many slow vs fast queries are executed.
this will make our metrics more resilient to outliers - outliers may greatly inflate the rolling average, but they will be recorded into separate buckets from the "regular" queries

this also has a chance of using less memory than the rolling average - we don't actually need to store the observations for any amount of time - we only count them into a static number of buckets (a single number each) and immediately discard the actual observation value.
this also eliminates the possibility of skipping observations if we make more than <window size> queries per <scrape duration> - every query will be visible, no matter how many we make and how much time passes between scrapes of the metrics endpoint.

@mini-bomba
mini-bomba marked this pull request as ready for review September 17, 2026 20:59
Comment thread src/databases/Postgres.ts Outdated
@ajayyy
ajayyy merged commit 121e1c6 into ajayyy:master Sep 17, 2026
3 of 4 checks passed
@mini-bomba
mini-bomba deleted the histogram-metrics branch September 17, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants