I agree with your comments. I think it should report when reaching the end of WAL too. I add the code to report the stats when finishing the current WAL segment file when timeout in the main loop and when reaching the end of WAL.
The following is not an improvement:
- /* Send WAL statistics to the stats collector. */
+ /* Send WAL statistics to stats collector */
The word "the" there makes it proper English. Your copy-pasting should have kept the existing good wording in the other locations rather than replace the existing location with the newly added incorrect wording.
This doesn't make sense:
* current WAL segment file to avoid loading stats collector.
Maybe "overloading" or "overwhelming"?
I see you removed the pgstat_send_wal(force) change. The rest of my comments on the v6 patch still stand I believe.