Fully featured low overhead profiler for Java EE and Java SE platforms.
Ultimate profiling and monitoring solution for Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

Custom Probe class

Moderators: Vladimir Kondratyev, Anton Katilin

Custom Probe class

Postby magnoyu » Mon Aug 28, 2017 5:02 am

Hi, I have a newbie question and wonder how to debug. So I tried to write my first custom probe class:

public final class ProbeQuote {
public static final String TABLE_NAME = "L1QuoteListener onQuote";

private static final class TestsTable extends Table {
private final ClassNameColumn myClass = new ClassNameColumn("L1QuoteListener Class");
private final StringColumn myMethod = new StringColumn("onQuote");

public TestsTable() {
super(ProbeQuote.class, TABLE_NAME, Table.MASK_FOR_LASTING_EVENTS);
}
}
private static final TestsTable T_TESTS = new TestsTable();

@MethodPattern({
"L1QuoteListener:onQuote(*)",
})
public static final class Test_Probe {
public static int onEnter(
@ClassRef final Class testClass,
@MethodName final String methodName
) {
final int rowIndex = T_TESTS.createRow();
T_TESTS.myMethod.setValue(rowIndex, methodName);
T_TESTS.myClass.setValue(rowIndex, testClass);
return rowIndex;
}

public static void onExit(
@OnEnterResult final int rowIndex,
@ThrownException final Throwable e
) {
T_TESTS.closeRow(rowIndex, e);
}
}
}

And I run it with intellij plugin and I can see the yjp log, the probe class is registered.

....
Registered: com.totoro.yourkit.ProbeQuote
....

vm param:
...... dll"=sampling,probe_on=com.totoro.yourkit.ProbeQuote,......

However, it's not showing up in the profiler when I look at it. (ie if any of the method pattern is wrong, I would imagine table is just empty?) But in the profiler, events table, it's not showing up even in the left hand side in the types of events (ie Socket/File/Thread/etc). How do I go about checking what I'm missing?

Thanks,
- Mag
magnoyu
 
Posts: 2
Joined: Mon Aug 28, 2017 4:57 am

Re: Custom Probe class

Postby Anton Katilin » Mon Aug 28, 2017 6:09 am

Hello Mag

The table is created when your probe class is loaded. Bytecode instrumentation does not immediately load the class, it only parses its meta-information (annotations, signatures etc.) Instead, the probe class loads implicitly when one of its callbacks is accessed by one of instrumented methods for the first time. If the callbacks are not accessed e.g. because the pattern is incorrect, you won't see the table even an empty one.

So I suggest to check the pattern first. Your pattern is "L1QuoteListener:onQuote(*)". Is the class indeed in the default package?

You may specify the agent startup option "debug=bci" to see in the agent log which methods are instrumented by which probe. Please ensure that the methods of interest are instrumented.

Please also ensure the methods are actually called.

Best regards,
Anton
Anton Katilin
 
Posts: 5565
Joined: Wed Aug 11, 2004 8:37 am

Re: Custom Probe class

Postby magnoyu » Mon Aug 28, 2017 11:14 am

Ya actually L1QuoteListener is a interface

public interface L1QuoteListener {
public void onQuote(long id, int bidSize, FixedPointNumber bidPrice, FixedPointNumber askPrice, int askSize);
}

Would it work?
magnoyu
 
Posts: 2
Joined: Mon Aug 28, 2017 4:57 am

Re: Custom Probe class

Postby Anton Katilin » Tue Aug 29, 2017 8:12 am

No. The pattern should explicitly specify classes by name, which in your case means you need to specify implementing classes.
Anton Katilin
 
Posts: 5565
Joined: Wed Aug 11, 2004 8:37 am


Return to Java Profiler

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 10 guests