Add debug and trace calls to apply and agent

Signed-off-by: Ken Barber <ken@bob.sh>