Create a context manager that captures stats histograms