This is an initial squashed commit of the work on a new feature for query metrics proposed in #18798.