SQL Server keep statistics for where it waits. This statistics can be find using various DMVs, the most famous of them is probably sys.dm_os_wait_stats. This DMV has accumulated wait stats for each type since you started SQL Server. Analyzing wait stats can give you an insight for your SQL Server that can be beneficial when doing performance tuning and such work.
What is not kept automatically is how the wait stats changes over time. This utility does just that.
We have a trail of captured values for (by default) 3 days with a denser capture rate. This will be how often you schedule the capture job, for instance once per minute.
We also have a trail of captured values for (by default) one year with a more course capture rate. Byt default we keep only one capture per day for this part.
SQL Server 2012 and later. The capturing part should work with 2008, some of the queries using LAG with the OVER clause which requires 2012.
We create a few tables and a couple of Agent jobs: