(conn)
return rows
Return metrics a about each `(database, table)` pair.
Return metrics a about each `(database, table)` pair.
Return metrics a about each ( database table ) pair .
def get_database_table_metrics(conn):
    # type: (rethinkdb.net.Connection) -> List[tuple]
    """
    Return metrics a about each `(database, table)` pair.
    """
    # For tables: stats['id'] has the form ['table', '<TABLE_ID>']
    is_table_stats_row = r.row['id'].nth(0) == 'table'
    table_id = r.row['id'].nth(1)

    joined_table_stats = STATS.filter(is_table_stats_row).eq_join(table_id, TABLE_CONFIG).run(conn)
    table_statuses = list(TABLE_STATUS.run(conn))

    rows = []  # type: List[tuple]
    for document in joined_table_stats:
        table_stats = document['left']
        table = document['right']
        # Join stats and statuses in Python.
        table_status = next(status for status in table_statuses if status['name'] == table['name'])

        row = (
            table['db'],
            table['name'],
            table_stats['query_engine']['read_docs_per_sec'],
            table_stats['query_engine']['written_docs_per_sec'],
            len(table_status['shards']),
            table_status['status']['ready_for_outdated_reads'],
            table_status['status']['ready_for_reads'],
            table_status['status']['ready_for_writes'],
            table_status['status']['all_replicas_ready'],
        )
        rows.append(row)

    return rows
def get_database_table_metrics ( conn ) : # type: (rethinkdb.net.Connection) -> List[tuple] # For tables: stats['id'] has the form ['table', '<TABLE_ID>'] is_table_stats_row = r . row [ 'id' ] . nth ( 0 ) == 'table' table_id = r . row [ 'id' ] . nth ( 1 ) joined_table_stats = STATS . filter ( is_table_stats_row ) . eq_join ( table_id , TABLE_CONFIG ) . run ( conn ) table_statuses = list ( TABLE_STATUS . run ( conn ) ) rows = [ ] # type: List[tuple] for document in joined_table_stats : table_stats = document [ 'left' ] table = document [ 'right' ] # Join stats and statuses in Python. table_status = next ( status for status in table_statuses if status [ 'name' ] == table [ 'name' ] ) row = ( table [ 'db' ] , table [ 'name' ] , table_stats [ 'query_engine' ] [ 'read_docs_per_sec' ] , table_stats [ 'query_engine' ] [ 'written_docs_per_sec' ] , len ( table_status [ 'shards' ] ) , table_status [ 'status' ] [ 'ready_for_outdated_reads' ] , table_status [ 'status' ] [ 'ready_for_reads' ] , table_status [ 'status' ] [ 'ready_for_writes' ] , table_status [ 'status' ] [ 'all_replicas_ready' ] , ) rows . append ( row ) return rows