refactor balancer metric emission code