Search in sources :

Example 6 with ThreadDumpMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot in project pinpoint by naver.

the class AgentActiveThreadDumpListTest method createThreadDumpList.

private AgentActiveThreadDumpList createThreadDumpList(Thread[] threads) {
    List<TActiveThreadDump> activeThreadDumpList = new ArrayList<>();
    for (Thread thread : threads) {
        TActiveThreadDump tActiveThreadDump = new TActiveThreadDump();
        tActiveThreadDump.setStartTime(System.currentTimeMillis() - ThreadLocalRandom.current().nextLong(100000));
        final ThreadDumpMetricSnapshot threadDumpMetricSnapshot = ThreadDumpUtils.createThreadDump(thread);
        final TThreadDump threadDump = this.threadDumpThriftMessageConverter.toMessage(threadDumpMetricSnapshot);
        tActiveThreadDump.setThreadDump(threadDump);
        activeThreadDumpList.add(tActiveThreadDump);
    }
    AgentActiveThreadDumpFactory factory = new AgentActiveThreadDumpFactory();
    return factory.create1(activeThreadDumpList);
}
Also used : TThreadDump(com.navercorp.pinpoint.thrift.dto.command.TThreadDump) ThreadDumpMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot) ArrayList(java.util.ArrayList) TActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)

Example 7 with ThreadDumpMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot in project pinpoint by pinpoint-apm.

the class GrpcThreadDumpMessageConverter method toMessage.

@Override
public PThreadDump toMessage(Object message) {
    if (message instanceof ThreadDumpMetricSnapshot) {
        final ThreadDumpMetricSnapshot threadDumpMetricSnapshot = (ThreadDumpMetricSnapshot) message;
        final PThreadDump.Builder threadDumpBuilder = PThreadDump.newBuilder();
        threadDumpBuilder.setThreadName(threadDumpMetricSnapshot.getThreadName());
        threadDumpBuilder.setThreadId(threadDumpMetricSnapshot.getThreadId());
        threadDumpBuilder.setBlockedTime(threadDumpMetricSnapshot.getBlockedTime());
        threadDumpBuilder.setBlockedCount(threadDumpMetricSnapshot.getBlockedCount());
        threadDumpBuilder.setWaitedTime(threadDumpMetricSnapshot.getWaitedTime());
        threadDumpBuilder.setWaitedCount(threadDumpMetricSnapshot.getWaitedCount());
        threadDumpBuilder.setInNative(threadDumpMetricSnapshot.isInNative());
        threadDumpBuilder.setSuspended(threadDumpMetricSnapshot.isSuspended());
        final PThreadState threadState = this.threadStateMessageConverter.toMessage(threadDumpMetricSnapshot.getThreadState());
        threadDumpBuilder.setThreadState(threadState);
        for (String stackTrace : threadDumpMetricSnapshot.getStackTrace()) {
            threadDumpBuilder.addStackTrace(stackTrace);
        }
        for (MonitorInfoMetricSnapshot monitorInfoMetricSnapshot : threadDumpMetricSnapshot.getLockedMonitors()) {
            final PMonitorInfo.Builder monitorInfoBuilder = PMonitorInfo.newBuilder();
            monitorInfoBuilder.setStackDepth(monitorInfoMetricSnapshot.getStackDepth());
            monitorInfoBuilder.setStackFrame(monitorInfoMetricSnapshot.getStackFrame());
            threadDumpBuilder.addLockedMonitor(monitorInfoBuilder.build());
        }
        if (threadDumpMetricSnapshot.getLockName() != null) {
            threadDumpBuilder.setLockName(threadDumpMetricSnapshot.getLockName());
        }
        threadDumpBuilder.setLockOwnerId(threadDumpMetricSnapshot.getLockOwnerId());
        if (threadDumpMetricSnapshot.getLockOwnerName() != null) {
            threadDumpBuilder.setLockOwnerName(threadDumpMetricSnapshot.getLockOwnerName());
        }
        for (String lockedSynchronizer : threadDumpMetricSnapshot.getLockedSynchronizers()) {
            threadDumpBuilder.addLockedSynchronizer(lockedSynchronizer);
        }
        return threadDumpBuilder.build();
    } else {
        return null;
    }
}
Also used : MonitorInfoMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.deadlock.MonitorInfoMetricSnapshot) PMonitorInfo(com.navercorp.pinpoint.grpc.trace.PMonitorInfo) ThreadDumpMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot) PThreadState(com.navercorp.pinpoint.grpc.trace.PThreadState) PThreadDump(com.navercorp.pinpoint.grpc.trace.PThreadDump)

Example 8 with ThreadDumpMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot in project pinpoint by pinpoint-apm.

the class GrpcStatMessageConverter method convertDeadlock.

private PDeadlock convertDeadlock(DeadlockMetricSnapshot deadlockMetricSnapshot) {
    // Only send id values that have already been sent
    final PDeadlock.Builder deadlockBuilder = PDeadlock.newBuilder();
    deadlockBuilder.setCount(deadlockMetricSnapshot.getDeadlockedThreadCount());
    for (ThreadDumpMetricSnapshot threadDumpMetricSnapshot : deadlockMetricSnapshot.getDeadlockedThreadList()) {
        final PThreadDump threadDump = this.threadDumpMessageConverter.toMessage(threadDumpMetricSnapshot);
        if (threadDump != null) {
            deadlockBuilder.addThreadDump(threadDump);
        }
    }
    return deadlockBuilder.build();
}
Also used : ThreadDumpMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot) PDeadlock(com.navercorp.pinpoint.grpc.trace.PDeadlock) PThreadDump(com.navercorp.pinpoint.grpc.trace.PThreadDump)

Example 9 with ThreadDumpMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot in project pinpoint by pinpoint-apm.

the class ActiveThreadDumpService method createTActiveThreadDump.

private TActiveThreadDump createTActiveThreadDump(ThreadDump threadDump) {
    final ActiveTraceSnapshot activeTraceInfo = threadDump.getActiveTraceSnapshot();
    final ThreadInfo threadInfo = threadDump.getThreadInfo();
    final ThreadDumpMetricSnapshot threadDumpMetricSnapshot = ThreadDumpUtils.createThreadDump(threadInfo);
    final TThreadDump tThreadDump = this.threadDumpThriftMessageConverter.toMessage(threadDumpMetricSnapshot);
    TActiveThreadDump activeThreadDump = new TActiveThreadDump();
    activeThreadDump.setStartTime(activeTraceInfo.getStartTime());
    activeThreadDump.setLocalTraceId(activeTraceInfo.getLocalTransactionId());
    activeThreadDump.setThreadDump(tThreadDump);
    if (activeTraceInfo.isSampled()) {
        activeThreadDump.setSampled(true);
        activeThreadDump.setTransactionId(activeTraceInfo.getTransactionId());
        activeThreadDump.setEntryPoint(activeTraceInfo.getEntryPoint());
    }
    return activeThreadDump;
}
Also used : ThreadInfo(java.lang.management.ThreadInfo) TThreadDump(com.navercorp.pinpoint.thrift.dto.command.TThreadDump) ThreadDumpMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot) ActiveTraceSnapshot(com.navercorp.pinpoint.profiler.context.active.ActiveTraceSnapshot) TActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)

Example 10 with ThreadDumpMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot in project pinpoint by pinpoint-apm.

the class ThreadDumpThriftMessageConverter method toMessage.

@Override
public TThreadDump toMessage(Object message) {
    if (message instanceof ThreadDumpMetricSnapshot) {
        final ThreadDumpMetricSnapshot threadDumpMetricSnapshot = (ThreadDumpMetricSnapshot) message;
        final TThreadDump threadDump = new TThreadDump();
        threadDump.setThreadName(threadDumpMetricSnapshot.getThreadName());
        threadDump.setThreadId(threadDumpMetricSnapshot.getThreadId());
        threadDump.setBlockedTime(threadDumpMetricSnapshot.getBlockedTime());
        threadDump.setBlockedCount(threadDumpMetricSnapshot.getBlockedCount());
        threadDump.setWaitedTime(threadDumpMetricSnapshot.getWaitedTime());
        threadDump.setWaitedCount(threadDumpMetricSnapshot.getWaitedCount());
        threadDump.setInNative(threadDumpMetricSnapshot.isInNative());
        threadDump.setSuspended(threadDumpMetricSnapshot.isSuspended());
        final TThreadState threadState = this.threadStateMessageConverter.toMessage(threadDumpMetricSnapshot.getThreadState());
        threadDump.setThreadState(threadState);
        for (String stackTrace : threadDumpMetricSnapshot.getStackTrace()) {
            threadDump.addToStackTrace(stackTrace);
        }
        for (MonitorInfoMetricSnapshot monitorInfoMetricSnapshot : threadDumpMetricSnapshot.getLockedMonitors()) {
            final TMonitorInfo tMonitorInfo = new TMonitorInfo();
            tMonitorInfo.setStackDepth(monitorInfoMetricSnapshot.getStackDepth());
            tMonitorInfo.setStackFrame(monitorInfoMetricSnapshot.getStackFrame());
            threadDump.addToLockedMonitors(tMonitorInfo);
        }
        threadDump.setLockName(threadDumpMetricSnapshot.getLockName());
        threadDump.setLockOwnerId(threadDumpMetricSnapshot.getLockOwnerId());
        threadDump.setLockOwnerName(threadDumpMetricSnapshot.getLockOwnerName());
        for (String lockedSynchronizer : threadDumpMetricSnapshot.getLockedSynchronizers()) {
            threadDump.addToLockedSynchronizers(lockedSynchronizer);
        }
        return threadDump;
    } else {
        return null;
    }
}
Also used : TThreadState(com.navercorp.pinpoint.thrift.dto.command.TThreadState) TMonitorInfo(com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo) MonitorInfoMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.deadlock.MonitorInfoMetricSnapshot) TThreadDump(com.navercorp.pinpoint.thrift.dto.command.TThreadDump) ThreadDumpMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot)

Aggregations

ThreadDumpMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot)20 TThreadDump (com.navercorp.pinpoint.thrift.dto.command.TThreadDump)10 PThreadDump (com.navercorp.pinpoint.grpc.trace.PThreadDump)6 TActiveThreadDump (com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)6 ThreadInfo (java.lang.management.ThreadInfo)6 ActiveTraceSnapshot (com.navercorp.pinpoint.profiler.context.active.ActiveTraceSnapshot)4 MonitorInfoMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.deadlock.MonitorInfoMetricSnapshot)4 ArrayList (java.util.ArrayList)4 PActiveThreadDump (com.navercorp.pinpoint.grpc.trace.PActiveThreadDump)2 PDeadlock (com.navercorp.pinpoint.grpc.trace.PDeadlock)2 PMonitorInfo (com.navercorp.pinpoint.grpc.trace.PMonitorInfo)2 PThreadState (com.navercorp.pinpoint.grpc.trace.PThreadState)2 DeadlockMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.deadlock.DeadlockMetricSnapshot)2 TDeadlock (com.navercorp.pinpoint.thrift.dto.TDeadlock)2 TMonitorInfo (com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo)2 TThreadState (com.navercorp.pinpoint.thrift.dto.command.TThreadState)2 AgentActiveThreadDumpFactory (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory)2