Repository navigation
Fix db_time undercount diagnostics - #2
Merged
Merged
Conversation
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 merge request improves request-level DB diagnostics to address
db_timeundercount visibility gaps and updates operational documentation for remote deployment and latency expectations.Problem
In some request traces, endpoint-level DB work appeared higher than
db_time_ms, making it hard to distinguish:This MR introduces explicit timing decomposition so production logs can explain latency more reliably.
What Changed
1. DB Timing Decomposition
Added request-scoped DB timing helpers and propagated them across key read paths.
New file:
app/observability/db_timing.pyget,execute+fetch, scalar reads).db_acquire_msdb_execute_fetch_msUpdated context model:
app/observability/context.pyUpdated middleware logging:
app/observability/middleware.pydb_acquire_msdb_execute_fetch_msdb_time_gap_ms(diagnostic delta between DB components and existing DB timer)2. Applied Timing Wrappers to Endpoints/Services
Integrated new timing helpers into API/service DB paths:
app/api/products.pyapp/api/categories.pyapp/services/product_service.pyapp/services/category_service.pyThis improves consistency between measured DB phases and endpoint latency diagnostics.
3. Documentation Improvements
Expanded README guidance and operational runbook content:
README.mdFiles Changed
README.mdapp/api/categories.pyapp/api/products.pyapp/observability/context.pyapp/observability/db_timing.py(new)app/observability/middleware.pyapp/services/category_service.pyapp/services/product_service.pyValidation
db_acquire_msdb_execute_fetch_msdb_time_gap_msExpected Impact