feat: emit func_name caller-symbol tag (#3422)#17
Merged
Conversation
`traceCaller()` already parses the V8 frame that holds the enclosing
function/method symbol (e.g. `UserService.list`, `reactionsRepo.findFavorites`)
— it was discarded by the regex that keeps only `path:line:col`. Capture it and
emit it as a new `func_name` SQLCommenter tag.
Unlike `file:line:col`, a symbol is edit-stable: it doesn't drift when code
above the call site changes, which makes captured-query → source-method mapping
reliable across revisions. `func_name` is the shared join key other adapters
(e.g. postgres-tracked-pool) already emit.
Capture-when-present, fall back to `file` alone: anonymous / `<anonymous>` /
top-level frames (and minified builds) emit `file` only, never an empty tag.
`traceCaller()` now returns `{ file, symbol? }`, threaded through the 0.4.0
per-query concurrency machinery unchanged — only the payload widened from a
string. Applied to drizzle, mikroorm, and typeorm; READMEs gain the row.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- @query-doctor/sqlcommenter-drizzle: 0.4.0 -> 0.5.0 - @query-doctor/sqlcommenter-mikroorm: 0.3.0 -> 0.4.0 - @query-doctor/sqlcommenter-typeorm: 0.3.0 -> 0.4.0 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Implements the producer half of Query-Doctor/Site#3422: capture the enclosing caller symbol from the same V8 stack frame
traceCaller()already parses, and emit it as a newfunc_nameSQLCommenter tag.Why
Provenance today is
file:line:colonly. Line/col drift when code above the call site changes, so mapping captured queries back to source against any other revision silently misattributes them (Query-Doctor/Site#3367). The enclosing method symbol (e.g.reactionsRepo.findFavorites) is edit-stable and is the join key that makes captured-query → source-method coverage mapping (Query-Doctor/Site#3418 / Query-Doctor/Site#3419) reliable without checking out the capture's exact commit.func_nameis the canonical key other adapters (postgres-tracked-pool) already emit.What changed
traceCaller()now returns{ file, symbol? }instead of a barefilestring. The symbol is parsed from the same frame already selected — no new frame-selection logic.func_nametag emitted when a symbol is present; falls back tofilealone when the frame is anonymous /<anonymous>/ top-level (never an empty tag).asyncprefixes are stripped.{ file, symbol? }payload is threaded through the 0.4.0 per-query concurrency machinery unchanged — only the payload widened fromstring.func_namerow.Verification (grounded in real V8 frames, not assumptions)
Probed actual frames first, then asserted:
loadRow; object method →Object.findFavorites; class method →UserService.list; arrow-assigned const →arrowAssigned.func_name,filestill emitted (the fallback contract).db_driver,file,func_name, …); assertedfileprecedesfunc_name.All suites pass: drizzle 26, mikroorm 31, typeorm 24 (dual ESM/CJS builds clean).
Versions
traceCaller's return shape changed, so a minor under 0.x).Refs: Query-Doctor/Site#3422, Query-Doctor/Site#3367, Query-Doctor/Site#3418, Query-Doctor/Site#3419. The Site consumer (
feat-caller-symbol-tag) already rendersfunc_name, so it displays the moment this publishes.🤖 Generated with Claude Code