elastic / elastic/apm-agent-java

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

Offen
#3,237 16 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
agent-java community
Vorherrschende Sprache
Java
Sterne
594
Forks
338
Ø Merge
1 T. 13 Std.
Gemergte PRs (30 T.)
25

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the supplied HelloController.test01 reflection example and run it on JDK 8 with apm-agent-attach 1.39.0. Compare the parameter metadata before and after the agent switches to RUNNING, then trace which agent instrumentation affects HelloController.test; done means documenting the cause and a verified fix or limitation.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
observability-sre
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.