refactor metrics and health check