otel: omit sql.rows and reset_session DB spans#28
Merged
Conversation
A week-long audit of service traces found ~two dozen orphan single-span traces: bare sql.rows / sql.conn.reset_session / sql.conn.query spans with no parent server span. They come from DB operations that run outside any HTTP request — connection-pool lifecycle (ResetSession on idle/returned conns) and ent's boot-time schema-migration introspection (pragma_foreign_key_list and friends, run by Schema.Create before the server is serving). otelsql roots each such operation on its own, so they surface as contextless single-span "traces". They are harmless but noisy, and the same sql.rows / reset_session span types also bloat every normal request trace (an IX detail page emitted ~14 of them out of 28 spans). Configure otelsql SpanOptions to omit both span types. This roughly halves the DB-span count per request trace, removes the orphan reset_session / rows traces entirely, and lowers overall trace volume. The sql.conn.query spans — the ones carrying db.statement, which is the actual signal — are retained. Only the traced path (PDBPLUS_OTEL_SQL on) is affected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Capture the otelsql span trimming (sql.rows / reset_session omitted). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code Metrics Report
Code coverage of files in pull request scope (92.3%)
Reported by octocov |
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
A week-long trace audit found ~two dozen orphan single-span traces — bare
sql.rows/sql.conn.reset_session/sql.conn.queryspans with no parent server span. They come from DB operations outside any HTTP request: connection-pool lifecycle (ResetSession) and ent's boot-time schema-migration introspection (pragma_foreign_key_listetc., run bySchema.Createbefore the server serves). otelsql roots each on its own, so they surface as contextless single-span "traces". Harmless but noisy — and the samesql.rows/reset_sessiontypes also bloat every normal trace (an IX page emitted ~14 of 28 spans as these).Change
Configure
otelsql.SpanOptions{OmitRows: true, OmitConnResetSession: true}. This:reset_session/rowstraces entirely,sql.conn.queryspans — the ones carryingdb.statement, the actual signal.Only the traced path (
PDBPLUS_OTEL_SQLon) is affected.Verification
go build,go test -race ./internal/database/...,go vet,golangci-lint runpass. Will confirm post-deploy that new traces no longer containsql.rows/reset_sessionspans.🤖 Generated with Claude Code