Skip to content

otel: omit sql.rows and reset_session DB spans#28

Merged
dotwaffle merged 2 commits into
mainfrom
otelsql-trim-spans
Jun 8, 2026
Merged

otel: omit sql.rows and reset_session DB spans#28
dotwaffle merged 2 commits into
mainfrom
otelsql-trim-spans

Conversation

@dotwaffle

Copy link
Copy Markdown
Owner

Summary

A week-long trace audit 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 outside any HTTP request: connection-pool lifecycle (ResetSession) and ent's boot-time schema-migration introspection (pragma_foreign_key_list etc., run by Schema.Create before the server serves). otelsql roots each on its own, so they surface as contextless single-span "traces". Harmless but noisy — and the same sql.rows/reset_session types also bloat every normal trace (an IX page emitted ~14 of 28 spans as these).

Change

Configure otelsql.SpanOptions{OmitRows: true, OmitConnResetSession: true}. This:

  • roughly halves the DB-span count per request trace,
  • removes the orphan reset_session/rows traces entirely,
  • lowers overall trace volume (already ~0.2% of budget),
  • retains the sql.conn.query spans — the ones carrying db.statement, the actual signal.

Only the traced path (PDBPLUS_OTEL_SQL on) is affected.

Verification

go build, go test -race ./internal/database/..., go vet, golangci-lint run pass. Will confirm post-deploy that new traces no longer contain sql.rows/reset_session spans.

🤖 Generated with Claude Code

dotwaffle and others added 2 commits June 8, 2026 13:23
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>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Code Metrics Report

Coverage Test Execution Time
80.9% 2m28s

Code coverage of files in pull request scope (92.3%)

Files Coverage
internal/database/database.go 92.3%

Reported by octocov

@dotwaffle dotwaffle merged commit 020acf1 into main Jun 8, 2026
2 checks passed
@dotwaffle dotwaffle deleted the otelsql-trim-spans branch June 8, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant