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
Add pool checkout to Server-Timing
#3442
Comments
There's a problem doing this, so currently we get the timings with: postgrest/src/PostgREST/App.hs Lines 146 to 149 in 85a4e35
But it's not possible to use the same pattern for the pool checkout time, we have to compute the time inside the pool. According to Nikita, we have to measure the checkout time (or wait time) like: executeObservedSession :: Pool -> Monitor -> Session -> IO ()
executeObservedSession pool monitor session = do
Monitor.incGauge monitor "db.client.connections.pending_requests"
startTime <- getCurrentTime
Pool.use pool do
liftIO $ do
endTime <- getCurrentTime
Monitor.observeHistogram monitor "db.client.connections.wait_time" (diffUTCTime endTime startTime)
Monitor.decGauge monitor "db.client.connections.pending_requests"
session (nikita-volkov/hasql-pool#40 (comment)) So while we could have a Metric (o new Observation) inside the pool, is not straightforward to get it out. Maybe we could use an IORef there, but it's kind of messy. |
Problem
Server-Timing currently conflates the pool checkout time with the transaction time. Meaning we cannot differentiate if a query took a lot of time or if acquiring the connection from the pool did.
Solution
Add a
pool-checkout
duration:Notes
Measuring check-in time (time to return the connection to the pool) doesn't make much sense in our case IMO, since we always return the connection right after finishing the transaction. This probably makes more sense in traditional three-tier apps where some business logic is done in the application layer while a pool connection is being used.
The text was updated successfully, but these errors were encountered: