Demystifying Java Instrumentation: The Engineering Behind the New Relic Java Agent
Briefly

Demystifying Java Instrumentation: The Engineering Behind the New Relic Java Agent
"The most critical thing that happens inside the premain method is that the agent (New Relic) calls instrumentation.addTransformer(myTransformer). This tells the JVM: 'From now on, before you finalize any class into memory, you must send it through this transformer first.'"
"Class Transformations are performed to inject additional behaviour to the bytecode of classes without changing the original source code. This makes the app code monitorable or rather observable. For instance, java.lang.instrument can instrument classes by altering bytecode at load-time."
"The New Relic Java agent is designed to be a 'pass-through' observer with a very small footprint. It does not store data locally on your disk before sending it to NRDB. Instead, it uses an in-memory 'Harvest Cycle' to batch data and send it out periodically."
Java agents initialize during JVM startup by receiving an Instrumentation object that allows direct interface with the class-loading apparatus. The premain method registers class transformers that intercept every class before it loads into memory, enabling bytecode modification to inject monitoring behavior. At startup, logging is configured, transformers are registered, and services initialize including Config Service, RPM Connection, Harvest Service, and Transaction tracking. The New Relic Java agent operates as a lightweight pass-through observer using in-memory harvest cycles to batch metrics and send them periodically to NRDB, avoiding local disk storage and minimizing application footprint.
Read at New Relic
Unable to calculate read time
[
|
]