Repository: launchbadge/sqlx
File: sqlx-core/src/pool/inner.rs (Rust)

Code before:
                        },
                        Err(permit) => if let Ok(guard) = self.try_increment_size(permit) {
                            // we can open a new connection
                            guard
                        } else {
                            // This can happen for a child pool that's at its connection limit,
                            // or if the pool was closed between `acquire_permit()` and
                            // `try_increment_size()`.
                            tracing::debug!("woke but was unable to acquire idle connection or open new one; retrying");
                            // If so, we're likely in the current-thread runtime if it's Tokio,
                            // and so we should yield to let any spawned return_to_pool() tasks
                            // execute.
                            crate::rt::yield_now().await;
                            continue;
                        }
                    };

                    // Attempt to connect...
                    return self.connect(deadline, guard).await;
                }
            }
        )
            .await
            .map_err(|_| Error::PoolTimedOut)??;

        let acquired_after = Instant::now() - acquire_started_at;

        let acquire_time_level = match self.acquire_slow_level {
            Some(level) => {
                if acquired_after >= self.options.acquire_slow_after {
                    private_tracing_dynamic_event!(
                        target: "sqlx::pool",
                        level,
                        aquired_after_secs = acquired_after.as_secs_f64(),
                        slow_acquire_threshold_secs = self.options.acquire_slow_after.as_secs_f64(),
                        "acquired connection, but time to acquire exceeded slow threshold"
                    );

                    // Suppress non-slow acquire logging
                    None
                } else {
                    // Fallback on non-slow logging, if configured
                    self.acquire_time_level
                }
            }
            // Slow logging not configured
            None => self.acquire_time_level,
        };

        if let Some(level) = acquire_time_level {
            private_tracing_dynamic_event!(

Review comment (suggestion):
```suggestion
        let acquired_after = acquire_started_at.elapsed();
```

Code after:
                        },
                        Err(permit) => if let Ok(guard) = self.try_increment_size(permit) {
                            // we can open a new connection
                            guard
                        } else {
                            // This can happen for a child pool that's at its connection limit,
                            // or if the pool was closed between `acquire_permit()` and
                            // `try_increment_size()`.
                            tracing::debug!("woke but was unable to acquire idle connection or open new one; retrying");
                            // If so, we're likely in the current-thread runtime if it's Tokio,
                            // and so we should yield to let any spawned return_to_pool() tasks
                            // execute.
                            crate::rt::yield_now().await;
                            continue;
                        }
                    };

                    // Attempt to connect...
                    return self.connect(deadline, guard).await;
                }
            }
        )
            .await
            .map_err(|_| Error::PoolTimedOut)??;

        let acquired_after = acquire_started_at.elapsed();

        let acquire_slow_level = self
            .acquire_slow_level
            .filter(|_| acquired_after > self.options.acquire_slow_threshold);

        if let Some(level) = acquire_slow_level {
            private_tracing_dynamic_event!(
                target: "sqlx::pool::acquire",
                level,
                aquired_after_secs = acquired_after.as_secs_f64(),
                slow_acquire_threshold_secs = self.options.acquire_slow_threshold.as_secs_f64(),
                "acquired connection, but time to acquire exceeded slow threshold"
            );
        } else if let Some(level) = self.acquire_time_level {
            private_tracing_dynamic_event!(
                target: "sqlx::pool::acquire",
                level,
                aquired_after_secs = acquired_after.as_secs_f64(),
                "acquired connection"
            );
        }

        Ok(acquired)
    }