Revert "Disable latency tracking due to performance problems"

This reverts commit 3dd57e9f38eb4b0ac6320706f38bb08db2549be5.
Update latency tracking code