@@ -41,7 +41,7 @@ use crate::{
4141 BlockRangeColumn , BlockRangeLowerBoundClause , BlockRangeUpperBoundClause , BLOCK_COLUMN ,
4242 BLOCK_RANGE_COLUMN , BLOCK_RANGE_CURRENT ,
4343 } ,
44- primary:: Namespace ,
44+ primary:: { Namespace , Site } ,
4545} ;
4646
4747/// Those are columns that we always want to fetch from the database.
@@ -2826,6 +2826,7 @@ pub struct FilterQuery<'a> {
28262826 range : FilterRange ,
28272827 block : BlockNumber ,
28282828 query_id : Option < String > ,
2829+ site : & ' a Site ,
28292830}
28302831
28312832/// String representation that is useful for debugging when `walk_ast` fails
@@ -2851,6 +2852,7 @@ impl<'a> FilterQuery<'a> {
28512852 range : EntityRange ,
28522853 block : BlockNumber ,
28532854 query_id : Option < String > ,
2855+ site : & ' a Site ,
28542856 ) -> Result < Self , QueryExecutionError > {
28552857 let sort_key = SortKey :: new ( order, collection, filter, block) ?;
28562858
@@ -2860,6 +2862,7 @@ impl<'a> FilterQuery<'a> {
28602862 range : FilterRange ( range) ,
28612863 block,
28622864 query_id,
2865+ site,
28632866 } )
28642867 }
28652868
@@ -3120,10 +3123,17 @@ impl<'a> QueryFragment<Pg> for FilterQuery<'a> {
31203123 return Ok ( ( ) ) ;
31213124 }
31223125
3126+ // Tag the query with various information to make connecting it to
3127+ // the GraphQL query it came from easier. The names of the tags are
3128+ // chosen so that GCP's Query Insights will recognize them
31233129 if let Some ( qid) = & self . query_id {
3124- out. push_sql ( "/* qid: " ) ;
3130+ out. push_sql ( "/* controller='filter',application='" ) ;
3131+ out. push_sql ( self . site . namespace . as_str ( ) ) ;
3132+ out. push_sql ( "',route='" ) ;
31253133 out. push_sql ( qid) ;
3126- out. push_sql ( " */\n " ) ;
3134+ out. push_sql ( "',action='" ) ;
3135+ out. push_sql ( & self . block . to_string ( ) ) ;
3136+ out. push_sql ( "' */\n " ) ;
31273137 }
31283138 // We generate four different kinds of queries, depending on whether
31293139 // we need to window and whether we query just one or multiple entity
0 commit comments