-
-
Notifications
You must be signed in to change notification settings - Fork 808
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
transform not working when attaching agentmain dynamically #1742
Comments
my goal is to print the execution time for each method execution. now I execute the spring HealthController.health() by curl, I can get response but no execution time print. |
TimingAdvice code
main code
pom.xml
|
Could you register an Agent builder.Listener to see if the classes you wonder about are picked up? |
I add the builder.Listener and can print typeName, even when I execute curl to HealthController.health() is also do print, but transform do nothing, no className print. Here's my code and result:
ByteBuddyListener:
|
I see an error in the log. What does the exception say? |
Thank you for your reply. I will go to the company on Monday to test what the printing error is. At that time, the project can only be debugged in the local network. Inspired by you, I started a very simple Spring project, and its Spring HealthController has been successfully adjusted. |
I found the issue. It's because the spring-test plugin I depend on introduces mockio, which relies on an older version 1.10. The latest version 1.15 that I'm using throws an error when using agentmain, with the following error message. So, to ensure compatibility across multiple projects and versions, I can only use the -javaagent mode, right? It works fine when using that. |
Can't you use dependency configuration to pin the latest version? |
If you use Maven, for example, you'd use dependency configuration. |
Thank you for your reply, I will check it again. |
Hey, I had a simple static agent that I attached with -javaagent and everything worked fine. Now I tried changing it to work dyamically in agentmain, it worked without println in transform, I don't no why.
I had a check in issue similarly, ref: #1164. But It didn't solve my problem. Here's my code:
I can see the "Agentmain initialized." and "Agent initialized successfully!" print when I attach the agent so I know it's being attached, but the transform is never called with no "className: xxx" print.
bytebuddy: 1.15.11
java: 1.8.0
The text was updated successfully, but these errors were encountered: