Open sgtsquiggs opened 1 year ago
Would these comments be static per query or would they be embedding dynamic values like a request ID? Dynamic values would make prepared statements ineffective (and pgx automatically prepares and caches statements by default).
The QueryRewriter interface could be used for regular queries but it wouldn't help CopyFrom and Commit.
If this feature wouldn't be outright rejected, I'm happy to submit a PR.
I'm open to the idea of some sort of SQL rewriting hook, but I do have several concerns:
Is your feature request related to a problem? Please describe. DataDog propagates tracing to the database via sql comments. There is no way to do this w/ the current tracing ifaces.
Describe the solution you'd like Add additional ifaces specifically for this feature that would allow injecting a comment infront of all sql sent to the db.
Describe alternatives you've considered CopyFrom, Commit, etc are hard-coded sql queries that cannot be modified without editing pgx source. You could get most of the rest working using the database/sql pgx iface.
If this feature wouldn't be outright rejected, I'm happy to submit a PR.