Fix server metrics to avoid NaN and Infinity