Add a SamplingHandler

It wraps around another handler, and only passes on some messages
based on the provided sampling handler.

This was originally written for MediaWiki: https://gerrit.wikimedia.org/r/181346
Merge remote-tracking branch 'legoktm/sampling'
Bring sampling handler in line with other wrapper handlers