Replies: 1 comment 6 replies
-
Hey @patsonluk ,
I'd also really recommend avoiding depending on too many libraries/frameworks and keeping the instrumentation code minimal; but if you're not able to do it then you can try splitting the jars/packages - hope that it works for you. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
We are experimenting with adding our custom instrumentation as an extension (
-Dotel.javaagent.experimental.initializer.jar
), and have some success by tagging our Instrumentation Module with@AutoService(InstrumentationModule.class)
.By overriding
additionalHelperClassNames
, we can get the advice to reference helper class of ours. Unfortunately, in more complex usage, which we reference more 3rd party library from our helper class (which the 3rd party libraries are packaged in our extension jar), it's unpractical to list out all the dependencies.Therefore, we modified our extension build to integrate the Muzzle plugin and override
isHelperClass
to make it scan all the usage of our helper class and all the 3rd party library dependencies (which we shaded to have our prefix, henceisHelperClass
can really catch them all). The issue though, is that the list grows too long (1k+ classes, since we reference frameworks like Guava), and exception ofMethod too large:
is thrown during muzzle code generation.By looking at the OT agent itself, it uses Muzzle plugin only to find the "helper" class (and not dependencies on other modules), as those dependencies are made available by appending the agent jar itself to the bootstrap loader path search https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/v1.1.0/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/OpenTelemetryAgent.java#L129 , which should make all the dependencies provided via the agent jar available to almost all classloader (except some oddball classloader, which might skip bootstrap loader path search/load class by resource?)
That means for us, we might be able to get around it by using non standard jvm option
-Xbootclasspath/a
(though non-standard option is bad?). So our questions are:@AutoService(InstrumentationModule.class)
a legit way to add custom instrumentation via extension (-Dotel.javaagent.experimental.initializer.jar
). Or is forking this repo the only way?Would it be possible if OT append extension jar to bootstrap classpath as well much like the the OT java agent itself?(this does not work, at least not in any trivial way, for example if we have a customConfigurablePropagatorProvider
implementation , and such implementation will be loaded byjava.util.ServiceLoader
, since the implementation is found in bootstrap classpath, it will be loaded by bootstrap class loader, however, when JVM tries to load the interface, which isConfigurablePropagatorProvider
, it runs intojava.lang.NoClassDefFoundError
due to such an interface not available to bootstrap class loader (it's only visible toAgentClassLoader
)Many thanks for your kind attention!
Beta Was this translation helpful? Give feedback.
All reactions