Repository navigation
Add SpanOptions.RowsChildOfQuery to make sql.rows spans children of query spans - #652
Merged
Merged
Conversation
…uery spans When multiple queries run concurrently under the same parent span, the sql.conn.query and sql.rows spans are emitted as siblings and cannot be correlated with each other. Add an opt-in SpanOptions.RowsChildOfQuery that creates the sql.rows span from the query span's context so it becomes a child of the sql.conn.query or sql.stmt.query span that produced it. When the query span is omitted or filtered out, the rows span falls back to the caller's span as its parent. Fixes #561
XSAM
force-pushed
the
branch/otelsql-issue-561-66f73e
branch
from
September 5, 2026 05:45
7a315d6 to
03eddef
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #652 +/- ##
=====================================
Coverage 89.4% 89.5%
=====================================
Files 15 15
Lines 579 582 +3
=====================================
+ Hits 518 521 +3
Misses 61 61 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
XSAM
added a commit
that referenced
this pull request
Sep 6, 2026
This release is the last to support [Go 1.25]. The next release will require at least [Go 1.26]. ### Added - Support testing of [Go 1.27]. (#650) - Add `WithSpanErrorAttributesGetter` option to set additional attributes (e.g., `db.response.status_code`) on spans when an operation returns an error. (#651) - Add `SpanOptions.RowsChildOfQuery` to create `sql.rows` spans as children of the `sql.conn.query` or `sql.stmt.query` span that produced them, so concurrent queries can be correlated with their result iteration. (#652) - Support `driver.RowsColumnScanner` on [Go 1.27]. (#649) ### Changed - Replace `ErrorTypeAttributes` with `ErrorTypeAttribute` to avoid allocating an additional slice. (#643) - Upgrade OTel to `v1.46.0`. (#644) ### Fixed - `db.client.operation.duration` histogram now uses the explicit bucket boundaries recommended by the OTel Semantic Conventions (`0.001` to `10` seconds) instead of the SDK defaults, which placed virtually all database operations in the first bucket. (#632) [Go 1.26]: https://go.dev/doc/go1.26 [Go 1.25]: https://go.dev/doc/go1.25 [Go 1.27]: https://go.dev/doc/go1.27
XSAM
added a commit
to boekkooi-impossiblecloud/XSAM-otelsql
that referenced
this pull request
Nov 14, 2026
Resolve conflicts with XSAM#643, XSAM#649, XSAM#651 and XSAM#652: - recordSpanError takes *config (needed for SpanErrorAttributesGetter) - otRows keeps pointer receivers and durationMetric, wrapped by wrapRowsColumnScanner - durationMetric uses ErrorTypeAttribute instead of ErrorTypeAttributes Co-Authored-By: Claude Fable 5.2 <[email protected]>
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
Fixes #561.
When multiple queries run concurrently under the same parent span,
sql.conn.queryandsql.rowsspans are emitted as siblings with no way to tell which rows span belongs to which query. As discussed in the issue, this adds an opt-in option to propagate the query span's context into the rows span.SpanOptions.RowsChildOfQuery. When set, thesql.rowsspan is created from the query span's context, so it becomes a child of thesql.conn.queryorsql.stmt.queryspan that produced it.OmitConnQuery, orSpanFilterreturns false), the rows span falls back to the caller's span as its parent, same as today.false, so existing behavior is unchanged.The doc comment notes the trade-off raised in #108: the rows span starts right before the query span ends, so the child appears after its parent on the timeline.
Test plan
TestOtConn_QueryContextandTestOtStmt_QueryContextnow run withRowsChildOfQueryon and off, and assert the rows span's parent in each case (query span, dummy parent span, or no parent).TestRowsContextunit test for the context selection.make lint license-checkandgo test -race ./...pass.🤖 Generated with Claude Code