Add a way to sample metrics using a callback