fix(sqlcommenter): prepend comment to beginning of query#4490
fix(sqlcommenter): prepend comment to beginning of query#4490RiyaChaturvedi37 wants to merge 12 commits intoopen-telemetry:mainfrom
Conversation
Previously the SQL comment was appended to the end of the query, which caused truncation issues in database query logs for long queries. This change moves the comment to the beginning of the query. Fixes open-telemetry#3583 Signed-off-by: RiyaChaturvedi37 <chaturvediriya37@gmail.com>
Signed-off-by: RiyaChaturvedi37 <chaturvediriya37@gmail.com>
Signed-off-by: RiyaChaturvedi37 <chaturvediriya37@gmail.com>
|
After implementing this change, I noticed it affects many existing tests and could be a breaking change for users who parse SQL logs expecting comment at the end. Should I proceed with updating all tests, or would maintainers prefer a different approach such as a configuration option to control comment position? |
MikeGoldsmith
left a comment
There was a problem hiding this comment.
A few concerns:
-
Breaking change — moving the comment from end to start changes behaviour for any downstream system that expects
sqlcommentercomments at the end of queries. The sqlcommenter spec defines comments at the end. This needs discussion on the issue (#3583) before we change the default behaviour — maybe an option to control position rather than switching it outright. -
Semicolon test looks wrong — the expected output for the semicolon case is
" /*...*/ Select 1"(no semicolon), but the input was"Select 1;". The semicolon is being dropped. -
Leading space — the prepended output starts with a space before the comment:
" /*...*/ SELECT 1". -
Line endings — same as #4482, the diff shows the entire file rewritten due to CRLF line endings. Please configure your editor/git to use Unix line endings (
git config core.autocrlf input).
Signed-off-by: RiyaChaturvedi37 <chaturvediriya37@gmail.com>
|
Hi @RiyaChaturvedi37 , thanks for working on this. I realized in my above comments that supporting the original requested feature is going to involve changes to several instrumentation libraries and not just this util:
Are you interested and available for submitting several PRs for this? |
|
Hi @tammy-baylis-swi, yes I'm interested and available! I'd be happy to submit PRs for each of these instrumentation libraries. Should I start with one library first for review, then proceed to the others once the approach is confirmed? Or would you prefer I submit them all at once? |
Problem
The SQL comment was appended to the end of the query, which caused
truncation issues in database query logs for long queries (e.g.
queries produced by Django in AWS RDS logs).
Fix
Changed the comment position from end to beginning of the query.
Before:
After:
Testing
The existing tests have been updated to reflect the new comment
position at the beginning of queries.
Fixes #3583