adds a background task to clean up the metrics database