-
Notifications
You must be signed in to change notification settings - Fork 319
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
Why can't I get the method‘s real parameter name when i use apm-agent? #3237
Comments
I'd guess that it gets lost when the class is transformed. Even if there is a way to maintain it (unlikely) we don't support that. Sorry |
However, this causes MyBatis to fail sql execution without explicitly specifying the parameter name using @param. The error message is as follows: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'ids' not found. Available parameters are [collection, list]。 @jackshirazi |
@jackshirazi I think it not impact mybatis, but also all frameworks that need to get some information by java reflect mechanism, so I think it is a bug that need to fix |
There is no guarantee in Java that a parameter name is retained, if you compile without debugging information it wouldn't be. Any framework that relies on that is buggy. I appreciate this is frustrating for you but we won't be priortising any work on this. Perhaps raising the issue with MyBatis might help? |
@jackshirazi I partially agree with your point, but this issue was introduced starting from version 1.25.0 not exists before, so it would cause regression issues for upgrading users and it is not mentioned in release notes, so I do not think not supporting is reasonable, please reestimate this issue, thanks!!! |
I really can't see this as a bug or breaking change in the agent, MyBatis is erroring on a implementation detail that is explicitly not guaranteed to hold in the JVM. Possible workarounds for you (but I don't know it will prevent the error):
|
@jackshirazi apm will erase the method real name even though I compile java code with -parameter, this is my concerned; |
I think it is hard to upgrade if this issue can not resolve, because I need to care all codes that use this feature @jackshirazi |
I've reopened it, but I still don't see this as an agent bug, more a feature request. But whether bug or feature request, this is not prioritized for the current quarter |
I tried to reproduce the issue and did not succeed at it using:
Without the agent, when compiled with On the bytecode level when looking at it with
When adding the agent with In order to verify what is happening here, it would be required to investigate the bytecode that is modified by the agent, in order to do that you will have to set How does the agent is setup in your applications here ? is is using The part that confuses me the most is that two invocations of the same method might yield different results, which seems to be more a JVM bug when the code is instrumented rather than something that the agent has control over. Here, having the exact JVM version that you are using would also be relevant. |
We had the same problem with JDK 17. The most important core feature, Spring SPEL, which is used in hundreds of our microservices, cannot work because the parameter names are erased. To be honest, I don't think Spring SPEL is a decent design relying on the parameter names, but this is what it is, the world most popular framework. Appreciate if you guys can reconsider whether or not to keep the parameter names. |
Hi @DanielYWoo , this is not something that is in our control as the agent just reads the existing bytecode that was compiled by the Java compiler. If the bytecode does not contain the information, there is nothing we can do to restore it. In order to investigate further your case I would suggest to inspect the compiled classes with If they aren't, then you need to find the right parameters for the |
Thanks for the tips but we do have the debug info. Sorry I don't have enough time to further debug this, fortunately the agent allows us to customize the instrument filters, so now we exclude the affected classes here and there to temporarily make it work. |
BTW, we also purchased another commercial APM tool which works without a problem. So I believe this could be a tricky bug in Elastic APM agent. But I just don't have time to take a deep look at this. (I am still working at 1:15 AM Saturday right now) |
Sorry, I completely misunderstood the issue here. I thought that the parameter names were not included in the original bytecode. However here the problem is that code that gets instrumented apparently looses the parameter names once transformed, which is a bit different. |
You are using "runtime attach" setup method, does the same issue also happens when you are using the That would be interesting (and quite quick) to know here, apparently some older JVMs discard the argument names when re-defining classes, which happens when using runtime attach. When using |
Why can't I get the method‘s real parameter name by reflect?
i can get the method‘s real parameter name When the program first started,but i can‘t get the method's real parameter name after printing this log.
my code like this
and log info like this
first result is “param name isnum” but the second result is “param name isarg0”,the expected result is “param name isnum”,how can i fix it?
my runtime environment is jdk8 and apm-agent-attach 1.39.0
The text was updated successfully, but these errors were encountered: