All Apps and Add-ons

JVM Instrumentation Agent: Unable to collect details on method execution

rtestu_splunk
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

Damien_Dallimor
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

Damien_Dallimor
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.

0 Karma

rtestu_splunk
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

rtestu_splunk
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

Damien_Dallimor
Ultra Champion

please share your full agent config file.

0 Karma
Get Updates on the Splunk Community!

2024 Splunk Career Impact Survey | Earn a $20 gift card for participating!

Hear ye, hear ye! The time has come again for Splunk's annual Career Impact Survey!  We need your help by ...

Optimize Cloud Monitoring

  TECH TALKS Optimize Cloud Monitoring Tuesday, August 13, 2024  |  11:00AM–12:00PM PST   Register to ...

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...