You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jason Keller edited this page Dec 2, 2025
·
2 revisions
About
The Java Agent is responsible for instrumenting applications running on the Java Virtual Machine (JVM). The agent extracts performance and analytic information from the JVM and sends it to data services. While the overall architecture here is largely accurate there are some aspects that will drift out of sync over time.
Instrumentation
The Java agent adds instrumentation by intercepting classes as they are loading and modifying the actual bytes.
The Java agent uses the -javaagentflag to tell the JVM an agent is running. This causes the agent's premain method to run prior to the main application. In the premain, the Java agent reads its configuration file, sets up services, and registers ClassFileTransformers with the JVM. Each ClassFileTransformer receives the bytes of every class prior to the class being fully loaded into the JVM. This allows the Java agent to add instrumentation before and after every method of interest.
While the agent has many ClassFileTransformers, the main transformer is the InstrumentationContextManager. This transformer hooks up the weaver, the code responsible for adding the instrumentation to classes. For the other transformers, see the ClassTransformerService.