Creating an InstrumentationModule that requires external library #9126
Replies: 1 comment 4 replies
-
I think you should be using |
Beta Was this translation helpful? Give feedback.
-
I think you should be using |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
I'm currently working on an
InstrumentationModule
that needs to be loaded as anExtension
. One of myAdviceMethod
s is responsible for creating a JSON text, and I'd like to utilize thecom.google.gson.Gson
Java library (or any other suitable library) for this purpose.The
build.gradle
file contains the following line:implementation("com.google.code.gson:gson:2.10.1")
, ensuring that thecom.google.gson
library exists within theextension.jar
.However, I've encountered an issue. I'm struggling to make Opentelemetry inject the
Gson
library into the application code. After reading the documentation, I tried using thegetAdditionalHelperClassNames
function. Unfortunately, sincecom.google.gson
comprises multiple classes, usinggetAdditionalHelperClassNames
would require listing all Gson classes in the correct order, which I believe is not the optimal solution.Is there a way to inject the entire
com.google.gson
library into the application code so that I can use it without explicit instrumentation?I did manage to make it work by adding the
com.google.com
library to theopentelemetry-javaagent
. However, this solution isn't ideal for me as I prefer to use the originalopentelemetry-javaagent
and add my code only as an extension.Any help would be greatly appreciated. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions