Repository navigation
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #46 +/- ##
==========================================
- Coverage 99.85% 99.81% -0.04%
==========================================
Files 15 17 +2
Lines 2760 3253 +493
==========================================
+ Hits 2756 3247 +491
- Misses 4 6 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Pool wait metrics currently lose the time spent by callers that cancel acquisition, while connection use time cannot distinguish
BEGINfrom the lifetime and termination of a transaction. This adds separate client-side lifecycle measurements and optional workload attribution so applications can identify which work holds or waits for connections.This PR is based directly on current
trunk(SQLx 0.9 / OpenTelemetry 0.33). It is independent of #41 and adds no dependencies or dependency-version changes.Measurements
sqlx_otel.connection.abandoned_wait.duration: records elapsed wait exactly once when a polled acquisition is dropped. Never-polled futures emit nothing; completed waits and pool timeouts retain their existing meanings.sqlx_otel.transaction.begin.duration: measuresBEGINafter acquisition, withok,error, andabandonedoutcomes.sqlx_otel.transaction.duration: measures from successfulBEGINto the terminal client observation, with commit/rollback success, error, abandonment, anddroppedoutcomes. Its seconds-based histogram extends to one hour.Outcomes deliberately describe what the client observed. An abandoned commit does not establish whether the server committed. Dropping a transaction queues rollback; it does not confirm completion, and can be an intentional guard-release path rather than an application error. No extra SQL, await, or SQLx ownership/Drop behavior is introduced.
Optional workload attribution
PoolAttribution::new("myapp.job.kind", "nightly_rollup").scope(future)adds one static key/value to wait, use, timeout, abandoned-wait, and transaction measurements. It is captured when acquisition first runs and stays with the lease through completion, even outside the original scope.Attributions that reuse a connection-identity or transaction-outcome key are ignored, so they cannot overwrite canonical labels. The scope is restored after each poll, including panic unwinding. Spawned tasks require explicit
PoolAttribution::inherit; pool-wide gauges/pending counts and query metrics remain untagged. Enabling a scope splits existing series, so consumers must aggregate across the added dimension to retain pool-wide totals.Validation
--all-targets --all-features -- -D warnings), formatting, and strict rustdoc passed.Tests cover cancellation versus timeouts, never-polled futures, interleaved/nested attribution scopes, spawned work, lease transfer, and real PostgreSQL boundary errors/cancellation. A response-gated commit test verifies that the server can commit while the client records
commit_abandoned.README, rustdoc, and changelog describe lifecycle boundaries, cardinality/propagation rules, and outcome limitations.