-
Notifications
You must be signed in to change notification settings - Fork 879
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
Embedded extension #3237
Embedded extension #3237
Conversation
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ExtensionLoader.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iNikem Do you see the flakiness only locally or also on CI? Either way can you file an issue?
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ExtensionLoader.java
Outdated
Show resolved
Hide resolved
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ExtensionLoader.java
Outdated
Show resolved
Hide resolved
We don't run examples' tests on CI. So only locally. Will file |
@iNikem I didn't confirm the fake backend image referenced in the examples smoketest is new enough for it, but we changed the path to |
Yes, that's it! Thank you! Fixed now. |
@@ -86,8 +136,13 @@ private static void addFileUrl(List<URL> result, File file) { | |||
} | |||
} | |||
|
|||
private static URLClassLoader getDelegate(ClassLoader parent, URL extensionUrl) { | |||
return new ExtensionClassLoader(new URL[] {extensionUrl}, parent); | |||
private static void extractFile(JarFile jarFile, JarEntry jarEntry, File outputFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outputDir
since we're extracting a jar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that parameter is actually a file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh oops - so the output file is a JAR file itself. extractFile
made me think the embedded JAR itself is getting extracted into its contents. I don't think unpackFile
had the same impression for me so may be a clearer name for people like me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We extract a file from jarEntry into an outputFile. Like "extract a file from a jar". How can this translate to a double extraction? :) But I can rename if you wish, no problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's two "Jar" variables there :) My brain processed it as extracting the second one. Maybe it's silly, so don't mind either way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any possibility to read directly from the embedded jar? Otherwise we limit possibility to run on read-only file system, a request we've gotten, and @tylerbenson has mentioned previously that they support.
I did not find it on the first try. But I don't think this is an actual blocker: on read-only system one can use external extensions jar. I can file a follow-up issue for that. |
FWIW, spring-boot has been extracting embedded JARs to file system for a loong time so it's tried and true :) |
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ExtensionClassLoader.java
Outdated
Show resolved
Hide resolved
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ExtensionClassLoader.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tests.
FWIW, spring-boot has been extracting embedded JARs to file system
I assumed that spring-boot used a class loader to read the embedded jars directly, given the requirement that the embedded jars have to be uncompressed?
File javaagentFile = installBootstrapJar(inst); | ||
AgentInitializer.initialize(inst, javaagentFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
constructor.newInstance(bootstrapUrl, innerJarFilename, agentParent); | ||
new AgentClassLoader(javaagentFile, innerJarFilename, agentParent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Builds on top of #3226 allowing to embed extension jar right inside javaagent jar for simplified deployment.
@anuraaga can you take a look at
examples/extension/src/test/java/com/example/javaagent/smoketest/SpringBootIntegrationTest.java
? It often time fails for me. Looks like later tests continue receiving spans from the previous tests./clear-requests
on fake backend does not work as expected or?