All Apps and Add-ons

JVM Instrumentation Agent: Unable to collect details on method execution

Splunk Employee
Splunk Employee

Hi all,

I’ve just downloaded the JVM Instrumentation Agent app to see what kind of metrics I could collect into Splunk.

I did a really simple try with a HelloWorld Java method that I execute once.
I added the agent like mentioned in the README, but get only one event into Splunk, the class loading.
I would have expected to get events for each method call since I have set:

trace.whitelist=com/splunk/tests/AgentTests
trace.methodEntered=true
trace.methodExited=true

Is there something I am missing?

Event I collect:

1455705580195
name=class_loaded
event_id=splunkagent
appName=myapp
appID=myjvm
className=com/splunk/tests/AgentTests

Thanks !!
Romain.

0 Karma
1 Solution

Ultra Champion

I have to guess here , as I can't see your source code , but it is likely that your test program is exiting before all the events have time to be sent. Try putting a Thread.sleep(10000) in your test code before it exits.

Some good info here also , from slide 38.

View solution in original post

0 Karma

Ultra Champion

I have to guess here , as I can't see your source code , but it is likely that your test program is exiting before all the events have time to be sent. Try putting a Thread.sleep(10000) in your test code before it exits.

Some good info here also , from slide 38.

View solution in original post

0 Karma

Splunk Employee
Splunk Employee

I exchanged with Damien offline and it seems that "weaving bytecode instructions for method tracing into the application main class is not performed".
I rearranged my code and everything is ok now !

Thanks Damien,
Romain.

0 Karma

Splunk Employee
Splunk Employee

Hi Damien,

Thanks for your quick answer !

I tried but same result ..

Here is the simple class:

package com.splunk.tests;

public class AgentTests {

public static void main(String[] args) {
    try {
        System.out.println("====== Say Hello ======");
        System.out.println(sayHello(args[0]));
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

public static String sayHello(String name) {
    return "Hello " + name;
}
}

And the execution:

java -javaagent:"/opt/test-splunk-agent/splunkagent.jar"  -jar mytests.jar romain

Romain.

0 Karma

Ultra Champion

please share your full agent config file.

0 Karma