This post will give a practical solution with complete code to monitor SQL server transactional replication latency in real time. My solution assumes you are using common distribution agent. With minor change you can also implement this for independent distribution agent.
This solution is a implementation of Kendra Little’s blog post.
Concept is to create a table with a single row storing current date-time (updated via a sql job every minute). Replicate that data to your subscriber and measure the difference between current time and time-stamp in subscriber table.
Before you run any of these code make sure you read …