Search in sources :

Example 11 with BasicThreadInfo

use of com.newrelic.agent.threads.BasicThreadInfo in project newrelic-java-agent by newrelic.

the class ProfileTest method testTopDownTree.

@Test
public void testTopDownTree() {
    IProfile profile = treeTestProfile();
    String normalizedThreadName = threadNameNormalizer.getNormalizedThreadName(new BasicThreadInfo(getMockedThreadInfo(0)));
    verifyTree(profile.getProfileTree(normalizedThreadName), new HashMap<String, Integer>() {

        private static final long serialVersionUID = 1L;

        {
            put("a", 4);
        }
    });
}
Also used : BasicThreadInfo(com.newrelic.agent.threads.BasicThreadInfo) Test(org.junit.Test)

Example 12 with BasicThreadInfo

use of com.newrelic.agent.threads.BasicThreadInfo in project newrelic-java-agent by newrelic.

the class TransactionProfileSessionImpl method noticeTracerStart.

@Override
public void noticeTracerStart(int signatureId, int tracerFlags, Tracer tracer) {
    if (!threadService.isCurrentThreadAnAgentThread()) {
        if (tracer == null) {
            discoveryProfile.noticeStartTracer(signatureId);
            Thread currentThread = Thread.currentThread();
            profile.addStackTrace(new BasicThreadInfo(currentThread), currentThread.getStackTrace(), true, ThreadType.BasicThreadType.OTHER);
        } else if (tracer.isLeaf() || tracer instanceof IgnoreChildSocketCalls) {
            if (stackTraceLimits.get(tracer.getMetricName()).getAndIncrement() < STACK_CAPTURE_LIMIT_PER_METRIC_PER_PERIOD) {
                tracer.setAgentAttribute(DefaultTracer.BACKTRACE_PARAMETER_NAME, Thread.currentThread().getStackTrace());
            }
        }
    }
}
Also used : BasicThreadInfo(com.newrelic.agent.threads.BasicThreadInfo) IgnoreChildSocketCalls(com.newrelic.agent.tracers.IgnoreChildSocketCalls)

Example 13 with BasicThreadInfo

use of com.newrelic.agent.threads.BasicThreadInfo in project newrelic-java-agent by newrelic.

the class Profile method getAgentThreadNames.

private Collection<Object> getAgentThreadNames() {
    Set<Long> agentThreadIds = ServiceFactory.getThreadService().getAgentThreadIds();
    Set<Object> names = new HashSet<>();
    for (long id : agentThreadIds) {
        ThreadInfo threadInfo = threadMXBean.getThreadInfo(id, 0);
        names.add(stringMap.addString(threadNameNormalizer.getNormalizedThreadName(new BasicThreadInfo(threadInfo))));
    }
    return new ArrayList<>(names);
}
Also used : ThreadInfo(java.lang.management.ThreadInfo) BasicThreadInfo(com.newrelic.agent.threads.BasicThreadInfo) BasicThreadInfo(com.newrelic.agent.threads.BasicThreadInfo) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

BasicThreadInfo (com.newrelic.agent.threads.BasicThreadInfo)13 ThreadInfo (java.lang.management.ThreadInfo)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)3 List (java.util.List)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 TransactionActivity (com.newrelic.agent.TransactionActivity)1 MetricName (com.newrelic.agent.metric.MetricName)1 ProfilerParameters (com.newrelic.agent.profile.ProfilerParameters)1 StatsEngine (com.newrelic.agent.stats.StatsEngine)1 StatsWork (com.newrelic.agent.stats.StatsWork)1 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)1 IgnoreChildSocketCalls (com.newrelic.agent.tracers.IgnoreChildSocketCalls)1 Tracer (com.newrelic.agent.tracers.Tracer)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 ThreadMXBean (java.lang.management.ThreadMXBean)1 Collection (java.util.Collection)1