@@ -380,6 +380,12 @@ impl Inner {
380380 let data_key = row. to_data_key ( ) ;
381381 st_tables. rows . insert ( RowId ( data_key) , row) ;
382382
383+ // Increment row count for st_tables
384+ DB_METRICS
385+ . rdb_num_table_rows
386+ . with_label_values ( & self . database_address , & ST_TABLES_ID . into ( ) )
387+ . inc ( ) ;
388+
383389 // Insert the columns into st_columns
384390 let first_col_id = schema. columns . first ( ) . unwrap ( ) . col_id ;
385391 for ( i, col) in schema. columns . into_iter ( ) . enumerate ( ) {
@@ -399,6 +405,11 @@ impl Inner {
399405 self . committed_state
400406 . get_or_create_table ( ST_COLUMNS_ID , & ST_COLUMNS_ROW_TYPE , & st_columns_schema ( ) ) ;
401407 st_columns. rows . insert ( RowId ( data_key) , row) ;
408+ // Increment row count for st_columns
409+ DB_METRICS
410+ . rdb_num_table_rows
411+ . with_label_values ( & self . database_address , & ST_COLUMNS_ID . into ( ) )
412+ . inc ( ) ;
402413 }
403414
404415 // If any columns are auto incrementing, we need to create a sequence
@@ -435,6 +446,11 @@ impl Inner {
435446 let row = ProductValue :: from ( row) ;
436447 let data_key = row. to_data_key ( ) ;
437448 st_sequences. rows . insert ( RowId ( data_key) , row) ;
449+ // Increment row count for st_sequences
450+ DB_METRICS
451+ . rdb_num_table_rows
452+ . with_label_values ( & self . database_address , & ST_SEQUENCES_ID . into ( ) )
453+ . inc ( ) ;
438454 }
439455 }
440456
@@ -463,6 +479,12 @@ impl Inner {
463479 let data_key = row. to_data_key ( ) ;
464480 st_constraints. rows . insert ( RowId ( data_key) , row) ;
465481
482+ // Increment row count for st_constraints
483+ DB_METRICS
484+ . rdb_num_table_rows
485+ . with_label_values ( & self . database_address , & ST_CONSTRAINTS_ID . into ( ) )
486+ . inc ( ) ;
487+
466488 //Check if add an index:
467489 match constraint. kind {
468490 x if x. is_unique ( ) => IndexSchema {
@@ -498,6 +520,12 @@ impl Inner {
498520 let row = ProductValue :: from ( row) ;
499521 let data_key = row. to_data_key ( ) ;
500522 st_indexes. rows . insert ( RowId ( data_key) , row) ;
523+
524+ // Increment row count for st_indexes
525+ DB_METRICS
526+ . rdb_num_table_rows
527+ . with_label_values ( & self . database_address , & ST_INDEXES_ID . into ( ) )
528+ . inc ( ) ;
501529 }
502530
503531 Ok ( ( ) )
@@ -1569,10 +1597,34 @@ impl Locking {
15691597
15701598 // Create the system tables and insert information about themselves into
15711599 // st_table, st_columns, st_indexes, and st_sequences.
1600+ DB_METRICS
1601+ . rdb_num_table_rows
1602+ . with_label_values ( & database_address, & st_table_schema ( ) . table_id . into ( ) )
1603+ . set ( 0 ) ;
15721604 datastore. bootstrap_system_table ( st_table_schema ( ) ) ?;
1605+
1606+ DB_METRICS
1607+ . rdb_num_table_rows
1608+ . with_label_values ( & database_address, & st_columns_schema ( ) . table_id . into ( ) )
1609+ . set ( 0 ) ;
15731610 datastore. bootstrap_system_table ( st_columns_schema ( ) ) ?;
1611+
1612+ DB_METRICS
1613+ . rdb_num_table_rows
1614+ . with_label_values ( & database_address, & st_constraints_schema ( ) . table_id . into ( ) )
1615+ . set ( 0 ) ;
15741616 datastore. bootstrap_system_table ( st_constraints_schema ( ) ) ?;
1617+
1618+ DB_METRICS
1619+ . rdb_num_table_rows
1620+ . with_label_values ( & database_address, & st_indexes_schema ( ) . table_id . into ( ) )
1621+ . set ( 0 ) ;
15751622 datastore. bootstrap_system_table ( st_indexes_schema ( ) ) ?;
1623+
1624+ DB_METRICS
1625+ . rdb_num_table_rows
1626+ . with_label_values ( & database_address, & st_sequences_schema ( ) . table_id . into ( ) )
1627+ . set ( 0 ) ;
15761628 datastore. bootstrap_system_table ( st_sequences_schema ( ) ) ?;
15771629 // TODO(kim): We need to make sure to have ST_MODULE in the committed
15781630 // state. `bootstrap_system_table` initializes the others lazily, but
@@ -1640,6 +1692,10 @@ impl Locking {
16401692 match write. operation {
16411693 Operation :: Delete => {
16421694 Self :: table_rows ( & mut inner, table_id, schema, row_type) . remove ( & RowId ( write. data_key ) ) ;
1695+ DB_METRICS
1696+ . rdb_num_table_rows
1697+ . with_label_values ( & inner. database_address , & table_id. into ( ) )
1698+ . dec ( ) ;
16431699 }
16441700 Operation :: Insert => {
16451701 let product_value = match write. data_key {
@@ -1657,6 +1713,10 @@ impl Locking {
16571713 } ;
16581714 Self :: table_rows ( & mut inner, table_id, schema, row_type)
16591715 . insert ( RowId ( write. data_key ) , product_value) ;
1716+ DB_METRICS
1717+ . rdb_num_table_rows
1718+ . with_label_values ( & inner. database_address , & table_id. into ( ) )
1719+ . inc ( ) ;
16601720 }
16611721 }
16621722 }
0 commit comments