SPARK-2134: Report metrics before application finishes

Could you add the `Unit` return type here and other places as well? I know much of the existing code doesn't do it but it would be good to add this for new code.