Rails 7.0 introduced support for Query Logs. These automatically append comments to all SQL statements that are executed, so it is easier to find queries that perform badly. Cloud Spanner does not include comments from the SQL string in the query statistics, meaning that in order for these comments to be useful, they need to be translated to request tags.
This change modifies the query execution path so the query transformer that is used by Query Logs is called by the Cloud Spanner provider. The comments that are added can then be translated to request tags. The latter requires that Query Logs is configured with two specific options:
ActiveRecord::QueryLogs.prepend_comment = true
The first tag must be { request_tag: "true" }
See the included sample application for a full working sample.
Rails 7.0 introduced support for Query Logs. These automatically append comments to all SQL statements that are executed, so it is easier to find queries that perform badly. Cloud Spanner does not include comments from the SQL string in the query statistics, meaning that in order for these comments to be useful, they need to be translated to request tags.
This change modifies the query execution path so the query transformer that is used by Query Logs is called by the Cloud Spanner provider. The comments that are added can then be translated to request tags. The latter requires that Query Logs is configured with two specific options:
ActiveRecord::QueryLogs.prepend_comment = true
{ request_tag: "true" }
See the included sample application for a full working sample.
Fixes #285