Skip to content
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

Javaagent doesn't work with java.net.spi.InetAddressResolverProvider #7130

Closed
hermannpencole opened this issue Nov 10, 2022 · 6 comments · Fixed by #11987
Closed

Javaagent doesn't work with java.net.spi.InetAddressResolverProvider #7130

hermannpencole opened this issue Nov 10, 2022 · 6 comments · Fixed by #11987
Labels
bug Something isn't working

Comments

@hermannpencole
Copy link

hermannpencole commented Nov 10, 2022

I use opentelemetry-javaagent - version: 1.19.2 :
INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 1.19.2

I work with java 18 because i need InetAddressResolverProvider : https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/net/spi/InetAddressResolverProvider.html.
When I launch my app without opentelemetry-javaagent the InetAddressResolverProvider works.
When I launch my app with opentelemetry-javaagent the InetAddressResolverProvider doesn't works.

@hermannpencole hermannpencole added the bug Something isn't working label Nov 10, 2022
@mateuszrzeszutek
Copy link
Member

The agent probably loads the resolver first, using the agent classloader (not the system CL, as the Javadoc suggests): https://github.com/openjdk/jdk/blob/f2acdfdcbd2a49c1167656e73b67b38b545f9472/src/java.base/share/classes/java/net/InetAddress.java#L477-L482
We might need to fix the CL before OpenTelemetry is initialized (it most likely resolves the exporter endpoint address)

@hermannpencole
Copy link
Author

Tks for your help mateuszrzeszutek : with your comment i found a workaround.
I extract code from my InetAddressResolverProvider into a new jar. And I declare this jar in launch option -Xbootclasspath/a

@serkan-ozal
Copy link
Contributor

This issue is similar to #10921

I have propose the following solution: #10921 (comment)

What do you think about it @mateuszrzeszutek @laurit

@laurit
Copy link
Contributor

laurit commented Aug 8, 2024

@serkan-ozal you are welcome to create a PR. If I were to attempt solving this I'd probably attempt transforming the InetAddress class so that instead of if (VM.isBooted()) it would have something like if (VM.isBooted() && AgentBooted.initialized) the AgentBooted.initialized flag could be set after agent initialization has completed. The transformation would need to be set up before we initialize opentelemetry sdk. Could do something similar to LaunchHelperClassFileTransformer.

@serkan-ozal
Copy link
Contributor

Hmm, thanks for pointing out. Will check LaunchHelperClassFileTransformer

@serkan-ozal
Copy link
Contributor

@laurit Here it is: #11987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants