Get tRPC procedure latency?

Fferdy5/4/2023
Hi all, is there a supported mechanism to run common code to all procedures, say if I want to get latency metrics. I want to run the same latency math on all my procedures. I could create a helper function that I just have to remember to wrap all my procedure code in but just wondering if there's some supported tRPC way of doing this?
Solution
Bbackbone5/4/2023
What about middleware
Fferdy5/4/2023
a middleware will only run before a procedure right?
Nnlucas5/4/2023
When a middleware calls opts.next() that triggers the rest of the middleware chain and eventually the procedure. You can await it and track the runtime
Nnlucas5/4/2023
(just make sure to return the result)