elastic / elastic/apm-agent-java

Why can't I get the method‘s real parameter name when i use apm-agent?

Open
#3,237 16 comments 0 reactions 0 assignees View on GitHub
agent-java community
Dominant language
Java
Stars
594
Forks
338
Avg merge
1d 13h
Merged PRs (30d)
25

Description

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.

```
2023-07-14 13:58:27,588 [http-nio-8081-exec-4] INFO co.elastic.apm.agent.servlet.ServletVersionInstrumentation - Servlet container info = Apache Tomcat/9.0.60

2023-07-14 13:58:27,710 [Attach Listener] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state
```

**my code like this**
```
@GetMapping("/test01")
public String test01() throws NoSuchMethodException {
Method testMethod = HelloController.class.getDeclaredMethod("test", int.class);
for (Parameter parameter : testMethod.getParameters()) {
System.out.println("param name is" + parameter.getName());
}
return "ok";
}

private static void test(int num) {

}
```

**and log info like this**
```
param name isnum

2023-07-14 13:58:27,588 [http-nio-8081-exec-4] INFO co.elastic.apm.agent.servlet.ServletVersionInstrumentation - Servlet container info = Apache Tomcat/9.0.60

2023-07-14 13:58:27,710 [Attach Listener] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state

param name isarg0
```

**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**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.