use of com.newrelic.agent.threads.BasicThreadInfo in project newrelic-java-agent by newrelic.
the class ProfileTest method testGetCallSiteCount.
@Test
public void testGetCallSiteCount() {
IProfile profile = getProfile();
StackTraceElement methodOnce = new StackTraceElement("com.acme.rocket", "launch", "rocket.java", 123);
StackTraceElement methodTwice = new StackTraceElement("com.acme.explosive", "detonate", "explosive.java", 123);
StackTraceElement methodCaller = new StackTraceElement("com.wileecoyote.cartoon", "show", "cartoon.java", 123);
ThreadInfo threadInfo1 = getMockedThreadInfo(0, methodOnce);
profile.addStackTrace(threadInfo1, true, ThreadType.BasicThreadType.OTHER);
ThreadInfo threadInfo2 = getMockedThreadInfo(0, methodOnce, methodCaller);
profile.addStackTrace(threadInfo2, true, ThreadType.BasicThreadType.OTHER);
ThreadInfo threadInfo3 = getMockedThreadInfo(0, methodTwice);
profile.addStackTrace(threadInfo3, true, ThreadType.BasicThreadType.OTHER);
ThreadInfo threadInfo4 = getMockedThreadInfo(0, methodTwice, methodCaller);
profile.addStackTrace(threadInfo4, true, ThreadType.BasicThreadType.OTHER);
String normalizedThreadName = threadNameNormalizer.getNormalizedThreadName(new BasicThreadInfo(threadInfo1));
Assert.assertEquals(0, profile.getSampleCount());
Assert.assertEquals(3, profile.getProfileTree(normalizedThreadName).getCallSiteCount());
}
use of com.newrelic.agent.threads.BasicThreadInfo in project newrelic-java-agent by newrelic.
the class ProfileTest method oneFrameStackIgnored.
@Test
public void oneFrameStackIgnored() {
IProfile profile = getProfile();
StackTraceElement methodOnce = new StackTraceElement("com.acme.rocket", "launch", "rocket.java", 123);
ThreadInfo threadInfo = getMockedThreadInfo(0, methodOnce);
profile.addStackTrace(threadInfo, true, ThreadType.BasicThreadType.OTHER);
String normalizedThreadName = threadNameNormalizer.getNormalizedThreadName(new BasicThreadInfo(threadInfo));
ProfileSegment methodOnceSegment = profile.getProfileTree(normalizedThreadName).getSegmentForMethod(methodOnce);
Assert.assertNull(methodOnceSegment);
}
use of com.newrelic.agent.threads.BasicThreadInfo in project newrelic-java-agent by newrelic.
the class ProfileTest method testAddStackTraces.
@Test
public void testAddStackTraces() {
IProfile profile = getProfile();
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
ThreadInfo threadInfo = getMockedThreadInfo(0, stackTrace);
profile.addStackTrace(threadInfo, true, ThreadType.BasicThreadType.OTHER);
String normalizedThreadName = threadNameNormalizer.getNormalizedThreadName(new BasicThreadInfo(threadInfo));
Assert.assertEquals(stackTrace.length, profile.getProfileTree(normalizedThreadName).getCallSiteCount());
profile.addStackTrace(getMockedThreadInfo(0, stackTrace), true, ThreadType.BasicThreadType.OTHER);
Assert.assertEquals(stackTrace.length, profile.getProfileTree(normalizedThreadName).getCallSiteCount());
stackTrace = Thread.currentThread().getStackTrace();
profile.addStackTrace(getMockedThreadInfo(0, stackTrace), true, ThreadType.BasicThreadType.OTHER);
Assert.assertEquals(stackTrace.length, profile.getProfileTree(normalizedThreadName).getCallSiteCount(), 2);
Assert.assertEquals(1, profile.getProfileTree(normalizedThreadName).getRootCount());
}
use of com.newrelic.agent.threads.BasicThreadInfo in project newrelic-java-agent by newrelic.
the class ProfileTest method testAddStackTrace.
@Test
public void testAddStackTrace() {
IProfile profile = getProfile();
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
ThreadInfo threadInfo1 = getMockedThreadInfo(0, stackTrace);
profile.addStackTrace(threadInfo1, true, ThreadType.BasicThreadType.OTHER);
String normalizedThreadName = threadNameNormalizer.getNormalizedThreadName(new BasicThreadInfo(threadInfo1));
Assert.assertEquals(stackTrace.length, profile.getProfileTree(normalizedThreadName).getCallSiteCount());
}
use of com.newrelic.agent.threads.BasicThreadInfo in project newrelic-java-agent by newrelic.
the class ProfileTest method testGetMethodCount.
@Test
public void testGetMethodCount() {
IProfile profile = getProfile();
StackTraceElement methodOnce = new StackTraceElement("com.acme.rocket", "launch", "rocket.java", 123);
StackTraceElement methodTwice = new StackTraceElement("com.acme.explosive", "detonate", "explosive.java", 123);
StackTraceElement methodCaller = new StackTraceElement("com.wileecoyote.cartoon", "show", "cartoon.java", 123);
ThreadInfo threadInfo1 = getMockedThreadInfo(0, methodOnce, methodCaller);
profile.addStackTrace(threadInfo1, true, ThreadType.BasicThreadType.OTHER);
profile.addStackTrace(getMockedThreadInfo(0, methodTwice), true, ThreadType.BasicThreadType.OTHER);
profile.addStackTrace(getMockedThreadInfo(0, methodTwice, methodCaller), true, ThreadType.BasicThreadType.OTHER);
String normalizedThreadName = threadNameNormalizer.getNormalizedThreadName(new BasicThreadInfo(threadInfo1));
Assert.assertEquals(3, profile.getProfileTree(normalizedThreadName).getMethodCount());
}
Aggregations