How does apm decides when does it needs to trace the methods

Check out this part of the docs: https://www.elastic.co/guide/en/apm/agent/java/current/java-method-monitoring.html

Let me know if you have any further questions.