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!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...