Refactor build-metrics to allow generating detailed metrics.