@@ -81,6 +81,7 @@ pub mod cachestore;
8181pub mod parser;
8282
8383use crate :: sql:: cachestore:: CacheStoreSqlService ;
84+ use crate :: util:: metrics;
8485use mockall:: automock;
8586
8687#[ automock]
@@ -944,6 +945,11 @@ impl SqlService for SqlServiceImpl {
944945 schema_name,
945946 if_not_exists,
946947 } => {
948+ app_metrics:: DATA_QUERIES . add_with_tags (
949+ 1 ,
950+ Some ( & vec ! [ metrics:: format_tag( "command" , "create_schema" ) ] ) ,
951+ ) ;
952+
947953 let name = schema_name. to_string ( ) ;
948954 let res = self . create_schema ( name, if_not_exists) . await ?;
949955 Ok ( Arc :: new ( DataFrame :: from ( vec ! [ res] ) ) )
@@ -963,6 +969,11 @@ impl SqlService for SqlServiceImpl {
963969 unique_key,
964970 partitioned_index,
965971 } => {
972+ app_metrics:: DATA_QUERIES . add_with_tags (
973+ 1 ,
974+ Some ( & vec ! [ metrics:: format_tag( "command" , "create_table" ) ] ) ,
975+ ) ;
976+
966977 let nv = & name. 0 ;
967978 if nv. len ( ) != 2 {
968979 return Err ( CubeError :: user ( format ! (
@@ -1127,6 +1138,11 @@ impl SqlService for SqlServiceImpl {
11271138 columns,
11281139 ..
11291140 } ) => {
1141+ app_metrics:: DATA_QUERIES . add_with_tags (
1142+ 1 ,
1143+ Some ( & vec ! [ metrics:: format_tag( "command" , "create_index" ) ] ) ,
1144+ ) ;
1145+
11301146 if table_name. 0 . len ( ) != 2 {
11311147 return Err ( CubeError :: user ( format ! (
11321148 "Schema's name should be present in table name but found: {}" ,
@@ -1163,6 +1179,11 @@ impl SqlService for SqlServiceImpl {
11631179 credentials,
11641180 or_update,
11651181 } => {
1182+ app_metrics:: DATA_QUERIES . add_with_tags (
1183+ 1 ,
1184+ Some ( & vec ! [ metrics:: format_tag( "command" , "create_source" ) ] ) ,
1185+ ) ;
1186+
11661187 if or_update {
11671188 let creds = match source_type. as_str ( ) {
11681189 "ksql" => {
@@ -1209,6 +1230,14 @@ impl SqlService for SqlServiceImpl {
12091230 columns,
12101231 if_not_exists,
12111232 } ) => {
1233+ app_metrics:: DATA_QUERIES . add_with_tags (
1234+ 1 ,
1235+ Some ( & vec ! [ metrics:: format_tag(
1236+ "command" ,
1237+ "create_partitioned_index" ,
1238+ ) ] ) ,
1239+ ) ;
1240+
12121241 if name. 0 . len ( ) != 2 {
12131242 return Err ( CubeError :: user ( format ! (
12141243 "Expected name for PARTITIONED INDEX in the form '<SCHEMA>.<INDEX>', found: {}" ,
@@ -1230,24 +1259,31 @@ impl SqlService for SqlServiceImpl {
12301259 CubeStoreStatement :: Statement ( Statement :: Drop {
12311260 object_type, names, ..
12321261 } ) => {
1233- match object_type {
1262+ let command = match object_type {
12341263 ObjectType :: Schema => {
12351264 self . db . delete_schema ( names[ 0 ] . to_string ( ) ) . await ?;
1265+ & "drop_schema"
12361266 }
12371267 ObjectType :: Table => {
12381268 let table = self
12391269 . db
12401270 . get_table ( names[ 0 ] . 0 [ 0 ] . to_string ( ) , names[ 0 ] . 0 [ 1 ] . to_string ( ) )
12411271 . await ?;
12421272 self . db . drop_table ( table. get_id ( ) ) . await ?;
1273+ & "drop_table"
12431274 }
12441275 ObjectType :: PartitionedIndex => {
12451276 let schema = names[ 0 ] . 0 [ 0 ] . value . clone ( ) ;
12461277 let name = names[ 0 ] . 0 [ 1 ] . value . clone ( ) ;
12471278 self . db . drop_partitioned_index ( schema, name) . await ?;
1279+ & "drop_partitioned_index"
12481280 }
12491281 _ => return Err ( CubeError :: user ( "Unsupported drop operation" . to_string ( ) ) ) ,
1250- }
1282+ } ;
1283+
1284+ app_metrics:: DATA_QUERIES
1285+ . add_with_tags ( 1 , Some ( & vec ! [ metrics:: format_tag( "command" , command) ] ) ) ;
1286+
12511287 Ok ( Arc :: new ( DataFrame :: new ( vec ! [ ] , vec ! [ ] ) ) )
12521288 }
12531289 CubeStoreStatement :: Statement ( Statement :: Insert {
@@ -1256,6 +1292,9 @@ impl SqlService for SqlServiceImpl {
12561292 source,
12571293 ..
12581294 } ) => {
1295+ app_metrics:: DATA_QUERIES
1296+ . add_with_tags ( 1 , Some ( & vec ! [ metrics:: format_tag( "command" , "insert" ) ] ) ) ;
1297+
12591298 let data = if let SetExpr :: Values ( Values ( data_series) ) = & source. body {
12601299 data_series
12611300 } else {
@@ -1295,14 +1334,19 @@ impl SqlService for SqlServiceImpl {
12951334 context. trace_obj . clone ( ) ,
12961335 )
12971336 . await ?;
1337+
12981338 // TODO distribute and combine
12991339 let res = match logical_plan {
13001340 QueryPlan :: Meta ( logical_plan) => {
13011341 app_metrics:: META_QUERIES . increment ( ) ;
13021342 Arc :: new ( self . query_planner . execute_meta_plan ( logical_plan) . await ?)
13031343 }
13041344 QueryPlan :: Select ( serialized, workers) => {
1305- app_metrics:: DATA_QUERIES . increment ( ) ;
1345+ app_metrics:: DATA_QUERIES . add_with_tags (
1346+ 1 ,
1347+ Some ( & vec ! [ metrics:: format_tag( "command" , "select" ) ] ) ,
1348+ ) ;
1349+
13061350 let cluster = self . cluster . clone ( ) ;
13071351 let executor = self . query_executor . clone ( ) ;
13081352 timeout (
0 commit comments