GeezerVison is showing github.com — [Feature] Add query metadata comments by DerekTBrown · Pull Request #4444 · sqlc-dev/sqlc
Conversation
DerekTBrown
commented
May 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #4489
Problem Statement
Database monitoring and tracing tools (ex. Datadog) rely on metadata comments to trace SQL statements. I am looking for an easy way to inject these into SQLC-generated statements, improving traceability and auditability of SQL queries.
Proposal
This adds a query_comments config block that prepends generated SQL with structured metadata comments in either sqlcommenter or marginalia format based on the tags specified in the SQLC comment:
version: "2"
sql:
- schema: "schema.sql"
query_comments:
enabled: true
format: "sqlcommenter"
tags:
- name
- filename
All generated SQL statements will then contain the tracking comment:
/*sqlc_name='GetAuthor',sqlc_filename='query.sql'*/
-- name: GetAuthor :one
SELECT id, name FROM authors WHERE id = $1
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
DerekTBrown
changed the title
[codex] Add query metadata comments
[Feature] Add query metadata comments
May 14, 2026
|
@DerekTBrown please open up an issue or a discussion with your feature request before submitting any code. Thanks.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.