global trace function.