refactor metrics API