...
- Agent is in disconnected mode
- Agent collects all classes that are loaded and safe the name of them
- When connection is attained again process all classes
Process loaded classes
- Perform everything in another thread from the loading one - in fact create a job in an executor or so
- saves us loading time
- batch send is possible
- we should log in the agent that the instrumentation is not done on the loading, but a bit later
- Calculate hashcode for the class
- Figure out if this class needs to be sent to the server
- Cache on the agent allows to quickly find the solution
- Three possible options: needs to be instrumented, does not need to be instrumented, new class
- We agreed that we currently do not keep the bytecode of the instrumented classes on the agent.
- Thus we only need to store the hashes of classes that should not be sent.
- If necessary send bytecode to the server
- Add the hash of the class to the list of hashes NEVER to be send. This is because we need to differentiate between classes that need instrumentation and unknown ones that do not need instrumentation
- (When we get back the bytecode with instrumentation we remove this class again as we are sure that this class is necessary for instrumentation)
- Always give back the original bytecode! The new bytecode will be asynchronously instrumented on the server and send back to the agent.
Process "bytecode resend" request (batch possible)
- Agent updates cache to mark this class to be instrumented/send
- Load bytecode from JVM (open)
- Send bytecode to the CMR
Process "Redefine" request (batch possible)
- Redefine class based on the given class
- Update RSC on the hook
- If the bytecode is marked as original, mark this class in the cache as "not needed for instrumentation", meaning ensure that this entry is within the list of hashes not to be send.
- If the bytecode is marked as non original, verify that cache has this class as "needed for instrumentation", meaning remove the entry from the list of hashes not to be send.
- Log output for the user? "XXX classes have been instrumented"
Update environment (instrumentation configuration)
...