Java capture overloaded method

Hello everyone,

I want to understand whether we can capture overloaded methods. We want to find which overloaded method was called with number of arguments and their type so we can use it for further correlation.

Welcome to our forum!

Both the Java agent and the .NET agent offer public APIs to decorate captured spans with custom labels. You can use this to add the overload argument details as span metadata.
If you need the actual span names to be dependent on the argument type and number, you may only be able to do that through Java agent public API.

Hi,

I got the traces for executed transactions but inside that only filename, method name, line number and class were captured. How do I get the exact method(with arguments) called if there are multiple methods with same name.

Are you talking about the captured stack traces? Please provide a screenshot explaining what you got and what you would wish to get

Yes, I'm talking about the captured stack traces. Let me explain my scenario.
Suppose I have a class Calculator and it has 2 methods -> add(int x, int y) and add(int x, int y, int z). When I call the add method having two arguments I get something like this as stack trace

{
              
                "filename" : "Calculator.java",
                "classname" : "com.example.Calculator",
                "line" : {
                  "number" : 125
                },
                "function" : "add",
                "module" : "com.example"
}

so here I'm getting only the method name but what I want is to have that function name, number of argument it contains and also their type, so final stack trace will look somewhat like this

{
              
                "filename" : "Calculator.java",
                "classname" : "com.example.Calculator",
                "line" : {
                  "number" : 125
                },
                "function" : {
                              "name":"add",
                             "arguments":2,
                              "type":["int","int"]
                             }
                "module" : "com.example"
}

Hi @Eyal_Koren,

Any updates ?

Sorry for the delay.
One thing you should realize is that the stack trace is based on the one that the JVM provides, which includes only these data. The line number is normally the way to distinguish between the different methods. So there is no way we can add any info to the stack trace.

However, if you are interested in specific methods, you can manually capture them and add any metadata you want, for example by annotating them. Take a look at the documentation about custom method capturing for other options.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.