Add database connection health check with latency - #446
Open
D-Bluemoon wants to merge 4 commits into
Open
Conversation
Add Prisma query telemetry for slow queries
|
@D-Bluemoon Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates PostgreSQL health checks to report real round-trip latency and server time, and it degrades overall service health when DB latency exceeds
1000ms.What changed
checkPostgresql()now measures latency withperformance.now()serverVersionfromSELECT 1, NOW() AS "serverVersion"{ healthy, latencyMs, serverVersion }degradedwhen PostgreSQL is connected but latency >1000mshealthyandserverVersionfields toDependencyHealthSELECT 1, NOW() AS "serverVersion"so the shared helper can capture server time and latencyRationale
SELECT 1only verified connectivity, not latency.performance.now()provides a more accurate in-process RTT measurement thanDate.now().healthyandserverVersionmakes the DB dependency health richer and more actionable.Fixes / Closes
Type of Change
Verification & Test Plan
Automated Tests
pnpm --filter @bettapay/validation testManual Verification
postgresqldependency now includeslatencyMs,healthy, andserverVersion.degradedwhen latency exceeds1000ms.Backend Services (BettaPay-Backend)
pnpm build)Checklist