-
Notifications
You must be signed in to change notification settings - Fork 874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal to contribute invokedynamic based instrumentation mechanism #8999
Comments
Per discussion at the Java SIG, one next step is to provide a walkthrough of how an existing instrumentation is expected to change if it moved across to this mechanism after the mechanism was implemented |
Per discussion at the Java SIG, the instrumentation using this mechanism is isolated and needs no shading but fully making the whole agent non-shaded using the ShadedClassLoader.java is not in this scope, but can be done in a subsequent scope if desired! |
This was added by @JonasKunz here providing a simple instrumentation change (Cassandra) and a complex one (Elasticsearch) |
The next step is to provide a roadmap architecture of the implementation, following which we'll aim to start providing PRs of individual components using the architecture as a reference until we get to a fully working instrumentation. After that the intention is to convert all the existing instrumentations to the invokedynamic non-inlined implementation, targeting the 2.0 release in October, which will terminate support for extensions that use inline instrumentation capability |
Here's a write-up of what we would envision as target architecture. Classloader StructureBased on the experience with the elastic APM agent I would envision the following "ideal" classloader structure for the OpenTelemetry Agent: The image shows the agent alongside two separate classloaders of the application being instrumented (App A and App B).
To keep things simple for a start, we can keep the This reduces the isolation benefits explained above, but should be simpler to implement for a start. If in the long run we often run into issues / user questions which would be avoided by the proper isolation, we can always add it afterwards. Invokedynamic Advice BootstrapingAs discussed in the previous SIG meetings, we will add a switch-method to We will adapt the OpenTelemetry Java Agent instrumentation logic to respect this We will inject an In the elastic APM agent the AFAIK, the OpenTelemetry Java Agent uses classloader instrumentations to guarantee visibility of injected bootstrap classes. Therefore we won't need to shade the Interaction of Invokedynamic-Advices with Java 9 modulesWhen instrumenting classes which are encapsulated within Java 9 modules, it is possible that the instrumentation needs to access non-exported contents of the modules. This usually shows by having to add In order to facilitate these use-cases, Accessing package-private / private membersThe inline/injection based instrumentation approach of the OpenTelemetry agent allows to access any package-private members by injecting accessor classes into the desired packages. Because we won't allow invokedynamic-instrumentations to perform this injection, we need a different way of gaining this access. This can be efficiently done by combining
Due to the You can find a PoC implementation here. SPI injectionAnother current use-case for injecting classes into application classloaders is to inject ServiceProviders.
Implementation PlanBased on the outlined architecture above, I would suggest the following implementation order:
|
Tracking
Related PRs
Note not for inclusion in this issue are preferred post completion task to remove shading from the agent
[COMPLETED] Phase 1 - Enabling invoke dynamic capability for instrumentations
Replace InstrumentationModule.isIndyModule() with a new interface in the internal package, perexample- this is no longer being done as it was decided to leave the method as is for now and change or deprecate as desired (as is not yet InstrumentationModule stable so deprecation and change is relatively quick)Phase 2a - Migrate simple instrumentation modules
Phase 2b - Additional support for muzzle and complex instrumentation modules
-- Make more tests run with indy #9729
-- donate LDAP instrumentation
-- Make more tests run with indy #9729
-- Implemented factory for generating invokedynamic proxy classes #9502
-- Add capability for invokedynamic InstrumentationModules to inject proxies #9565
-- Allow injection of helper bytecode as resources #9752
InstrumentationModules
to optionally share theirInstrumentationModuleClassloader
(see this discussion)Phase 3 - Migrate remaining instrumentation modules
Proposal
Contribute alternative invokedynamic based instrumentation mechanism to the OpenTelemetry Java agent, with no required changes to the existing OpenTelemetry instrumentation mechanism or instrumentations
Benefits to OpenTelemetry of this contribution and mechanism
Benefits to Elastic
Background
The text was updated successfully, but these errors were encountered: