I've been looking at some locking and blocking scenarios lately, and wanted to do some real-time investigation as well as some logging over time.
Have you seen Erland Sommarskog's beta_lockinfo? It's pretty nice. But it didn't quite fit my needs.
I went with this instead. With each iteration, grab just the lock waiters from dm_os_waiting_tasks - and just those with waits longer than 1000 ms. Convert resource_description to XML, and decode the attributes so I can potentially manipulate it.
The REPLACE occurrences below are to correct for formatting issues in the resource_description text which keep it from converting to conforming XML. Hope I got them all.
Here's the BOL link for SQL Server 2017 sys.dm_os_waiting_tasks.