Converted MetricsCollector.collectMetricsForResponse into a more functional style.