Search in sources :

Example 1 with PAgentStat

use of com.navercorp.pinpoint.grpc.trace.PAgentStat in project pinpoint by naver.

the class StatClientMock method agentStat.

public void agentStat(final int count) {
    StreamObserver<Empty> responseObserver = getResponseObserver();
    StreamObserver<PStatMessage> requestObserver = statStub.sendAgentStat(responseObserver);
    for (int i = 0; i < count; i++) {
        final PAgentStat agentStat = PAgentStat.newBuilder().build();
        final PStatMessage statMessage = PStatMessage.newBuilder().setAgentStat(agentStat).build();
        requestObserver.onNext(statMessage);
    }
    requestObserver.onCompleted();
}
Also used : Empty(com.google.protobuf.Empty) PAgentStat(com.navercorp.pinpoint.grpc.trace.PAgentStat) PStatMessage(com.navercorp.pinpoint.grpc.trace.PStatMessage)

Example 2 with PAgentStat

use of com.navercorp.pinpoint.grpc.trace.PAgentStat in project pinpoint by naver.

the class GrpcStatMessageConverter method toMessage.

@Override
public GeneratedMessageV3 toMessage(MetricType message) {
    if (message instanceof AgentStatMetricSnapshotBatch) {
        final AgentStatMetricSnapshotBatch agentStatMetricSnapshotBatch = (AgentStatMetricSnapshotBatch) message;
        final PAgentStatBatch.Builder agentStatBatchBuilder = PAgentStatBatch.newBuilder();
        // Skip agentId, startTimestamp
        for (AgentStatMetricSnapshot agentStatMetricSnapshot : agentStatMetricSnapshotBatch.getAgentStats()) {
            final PAgentStat agentStat = converAgentStat(agentStatMetricSnapshot);
            agentStatBatchBuilder.addAgentStat(agentStat);
        }
        return agentStatBatchBuilder.build();
    } else if (message instanceof AgentStatMetricSnapshot) {
        final AgentStatMetricSnapshot agentStatMetricSnapshot = (AgentStatMetricSnapshot) message;
        final PAgentStat agentStat = converAgentStat(agentStatMetricSnapshot);
        return agentStat;
    } else if (message instanceof AgentCustomMetricSnapshotBatch) {
        final AgentCustomMetricSnapshotBatch agentCustomMetricSnapshotBatch = (AgentCustomMetricSnapshotBatch) message;
        final PCustomMetricMessage pCustomMetricMessage = customMetricMessageConverter.toMessage(agentCustomMetricSnapshotBatch);
        return pCustomMetricMessage;
    } else if (message instanceof AgentUriStatData) {
        final AgentUriStatData agentUriStatData = (AgentUriStatData) message;
        final PAgentUriStat agentUriStat = uriStatMessageConverter.toMessage(agentUriStatData);
        return agentUriStat;
    }
    return null;
}
Also used : AgentStatMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot) PAgentStatBatch(com.navercorp.pinpoint.grpc.trace.PAgentStatBatch) AgentUriStatData(com.navercorp.pinpoint.profiler.monitor.metric.uri.AgentUriStatData) PAgentStat(com.navercorp.pinpoint.grpc.trace.PAgentStat) PCustomMetricMessage(com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage) PAgentUriStat(com.navercorp.pinpoint.grpc.trace.PAgentUriStat) AgentStatMetricSnapshotBatch(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch) AgentCustomMetricSnapshotBatch(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch)

Example 3 with PAgentStat

use of com.navercorp.pinpoint.grpc.trace.PAgentStat in project pinpoint by naver.

the class StatService method sendAgentStat.

@Override
public StreamObserver<PStatMessage> sendAgentStat(StreamObserver<Empty> responseObserver) {
    StreamObserver<PStatMessage> observer = new StreamObserver<PStatMessage>() {

        @Override
        public void onNext(PStatMessage statMessage) {
            if (isDebug) {
                logger.debug("Send PAgentStat={}", MessageFormatUtils.debugLog(statMessage));
            }
            if (statMessage.hasAgentStat()) {
                final Message<PAgentStat> message = newMessage(statMessage.getAgentStat(), DefaultTBaseLocator.AGENT_STAT);
                send(message, responseObserver);
            } else if (statMessage.hasAgentStatBatch()) {
                final Message<PAgentStatBatch> message = newMessage(statMessage.getAgentStatBatch(), DefaultTBaseLocator.AGENT_STAT_BATCH);
                send(message, responseObserver);
            } else if (statMessage.hasAgentUriStat()) {
                final Message<PAgentUriStat> message = newMessage(statMessage.getAgentUriStat(), DefaultTBaseLocator.AGENT_URI_STAT);
                send(message, responseObserver);
            } else {
                if (isDebug) {
                    logger.debug("Found empty stat message {}", MessageFormatUtils.debugLog(statMessage));
                }
            }
        }

        @Override
        public void onError(Throwable throwable) {
            final StatusError statusError = StatusErrors.throwable(throwable);
            if (statusError.isSimpleError()) {
                logger.info("Failed to stat stream, cause={}", statusError.getMessage());
            } else {
                logger.warn("Failed to stat stream, cause={}", statusError.getMessage(), statusError.getThrowable());
            }
        }

        @Override
        public void onCompleted() {
            com.navercorp.pinpoint.grpc.Header header = ServerContext.getAgentInfo();
            logger.info("onCompleted {}", header);
            responseObserver.onNext(Empty.newBuilder().build());
            responseObserver.onCompleted();
        }
    };
    return observer;
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) Message(com.navercorp.pinpoint.io.request.Message) DefaultMessage(com.navercorp.pinpoint.io.request.DefaultMessage) PStatMessage(com.navercorp.pinpoint.grpc.trace.PStatMessage) PAgentStat(com.navercorp.pinpoint.grpc.trace.PAgentStat) PAgentUriStat(com.navercorp.pinpoint.grpc.trace.PAgentUriStat) PStatMessage(com.navercorp.pinpoint.grpc.trace.PStatMessage) StatusError(com.navercorp.pinpoint.grpc.StatusError)

Example 4 with PAgentStat

use of com.navercorp.pinpoint.grpc.trace.PAgentStat in project pinpoint by naver.

the class GrpcStatMessageConverter method converAgentStat.

private PAgentStat converAgentStat(final AgentStatMetricSnapshot agentStatMetricSnapshot) {
    final PAgentStat.Builder agentStatBuilder = PAgentStat.newBuilder();
    agentStatBuilder.setTimestamp(agentStatMetricSnapshot.getTimestamp());
    agentStatBuilder.setCollectInterval(agentStatMetricSnapshot.getCollectInterval());
    // Skip agent information(agentId, startTimestamp)
    // Metric
    final JvmGcMetricSnapshot jvmGcMetricSnapshot = agentStatMetricSnapshot.getGc();
    if (jvmGcMetricSnapshot != null) {
        final PJvmGc jvmGc = convertJvmGc(jvmGcMetricSnapshot);
        agentStatBuilder.setGc(jvmGc);
    }
    final CpuLoadMetricSnapshot cpuLoadMetricSnapshot = agentStatMetricSnapshot.getCpuLoad();
    if (cpuLoadMetricSnapshot != null) {
        final PCpuLoad cpuLoad = convertCpuLoad(cpuLoadMetricSnapshot);
        agentStatBuilder.setCpuLoad(cpuLoad);
    }
    final TransactionMetricSnapshot transactionMetricSnapshot = agentStatMetricSnapshot.getTransaction();
    if (transactionMetricSnapshot != null) {
        final PTransaction transaction = convertTransaction(transactionMetricSnapshot);
        agentStatBuilder.setTransaction(transaction);
    }
    final ActiveTraceHistogram activeTraceHistogram = agentStatMetricSnapshot.getActiveTrace();
    if (activeTraceHistogram != null) {
        final PActiveTrace activeTrace = convertActiveTrace(activeTraceHistogram);
        agentStatBuilder.setActiveTrace(activeTrace);
    }
    final DataSourceMetricSnapshot dataSourceMetricSnapshot = agentStatMetricSnapshot.getDataSourceList();
    if (dataSourceMetricSnapshot != null) {
        final PDataSourceList dataSourceList = convertDataSourceList(dataSourceMetricSnapshot);
        agentStatBuilder.setDataSourceList(dataSourceList);
    }
    final ResponseTimeValue responseTimeValue = agentStatMetricSnapshot.getResponseTime();
    if (responseTimeValue != null) {
        final PResponseTime responseTime = convertResponseTime(responseTimeValue);
        agentStatBuilder.setResponseTime(responseTime);
    }
    final DeadlockMetricSnapshot deadlockMetricSnapshot = agentStatMetricSnapshot.getDeadlock();
    if (deadlockMetricSnapshot != null) {
        final PDeadlock deadlock = convertDeadlock(deadlockMetricSnapshot);
        agentStatBuilder.setDeadlock(deadlock);
    }
    final FileDescriptorMetricSnapshot fileDescriptorMetricSnapshot = agentStatMetricSnapshot.getFileDescriptor();
    if (fileDescriptorMetricSnapshot != null) {
        final PFileDescriptor fileDescriptor = convertFileDescriptor(fileDescriptorMetricSnapshot);
        agentStatBuilder.setFileDescriptor(fileDescriptor);
    }
    final BufferMetricSnapshot bufferMetricSnapshot = agentStatMetricSnapshot.getDirectBuffer();
    if (bufferMetricSnapshot != null) {
        final PDirectBuffer directBuffer = convertDirectBuffer(bufferMetricSnapshot);
        agentStatBuilder.setDirectBuffer(directBuffer);
    }
    final TotalThreadMetricSnapshot totalThreadMetricSnapshot = agentStatMetricSnapshot.getTotalThread();
    if (totalThreadMetricSnapshot != null) {
        final PTotalThread totalThread = convertTotalThread(totalThreadMetricSnapshot);
        agentStatBuilder.setTotalThread(totalThread);
    }
    final LoadedClassMetricSnapshot loadedClassMetricSnapshot = agentStatMetricSnapshot.getLoadedClassCount();
    if (loadedClassMetricSnapshot != null) {
        final PLoadedClass loadedClass = convertLoadedClass(loadedClassMetricSnapshot);
        agentStatBuilder.setLoadedClass(loadedClass);
    }
    return agentStatBuilder.build();
}
Also used : PJvmGc(com.navercorp.pinpoint.grpc.trace.PJvmGc) PTransaction(com.navercorp.pinpoint.grpc.trace.PTransaction) ResponseTimeValue(com.navercorp.pinpoint.profiler.monitor.metric.response.ResponseTimeValue) PLoadedClass(com.navercorp.pinpoint.grpc.trace.PLoadedClass) BufferMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.buffer.BufferMetricSnapshot) PDataSourceList(com.navercorp.pinpoint.grpc.trace.PDataSourceList) TotalThreadMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.totalthread.TotalThreadMetricSnapshot) PAgentStat(com.navercorp.pinpoint.grpc.trace.PAgentStat) PActiveTrace(com.navercorp.pinpoint.grpc.trace.PActiveTrace) FileDescriptorMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.filedescriptor.FileDescriptorMetricSnapshot) PActiveTraceHistogram(com.navercorp.pinpoint.grpc.trace.PActiveTraceHistogram) ActiveTraceHistogram(com.navercorp.pinpoint.profiler.context.active.ActiveTraceHistogram) CpuLoadMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.cpu.CpuLoadMetricSnapshot) PCpuLoad(com.navercorp.pinpoint.grpc.trace.PCpuLoad) PFileDescriptor(com.navercorp.pinpoint.grpc.trace.PFileDescriptor) PDirectBuffer(com.navercorp.pinpoint.grpc.trace.PDirectBuffer) DataSourceMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.datasource.DataSourceMetricSnapshot) JvmGcMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.JvmGcMetricSnapshot) PResponseTime(com.navercorp.pinpoint.grpc.trace.PResponseTime) DeadlockMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.deadlock.DeadlockMetricSnapshot) LoadedClassMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.loadedclass.LoadedClassMetricSnapshot) TransactionMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.transaction.TransactionMetricSnapshot) PDeadlock(com.navercorp.pinpoint.grpc.trace.PDeadlock) PTotalThread(com.navercorp.pinpoint.grpc.trace.PTotalThread)

Example 5 with PAgentStat

use of com.navercorp.pinpoint.grpc.trace.PAgentStat in project pinpoint by naver.

the class GrpcAgentStatBatchMapper method map.

public AgentStatBo map(final PAgentStatBatch agentStatBatch, final Header header) {
    if (agentStatBatch == null) {
        return null;
    }
    final String agentId = header.getAgentId();
    final long startTimestamp = header.getAgentStartTime();
    final AgentStatBo.Builder builder = new AgentStatBo.Builder(agentId, startTimestamp);
    for (PAgentStat agentStat : agentStatBatch.getAgentStatList()) {
        this.mapper.map(agentStat, builder);
    }
    return builder.build();
}
Also used : AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) PAgentStat(com.navercorp.pinpoint.grpc.trace.PAgentStat)

Aggregations

PAgentStat (com.navercorp.pinpoint.grpc.trace.PAgentStat)6 PAgentUriStat (com.navercorp.pinpoint.grpc.trace.PAgentUriStat)2 PDeadlock (com.navercorp.pinpoint.grpc.trace.PDeadlock)2 PStatMessage (com.navercorp.pinpoint.grpc.trace.PStatMessage)2 Empty (com.google.protobuf.Empty)1 AgentEventBo (com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)1 AgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo)1 StatusError (com.navercorp.pinpoint.grpc.StatusError)1 PActiveTrace (com.navercorp.pinpoint.grpc.trace.PActiveTrace)1 PActiveTraceHistogram (com.navercorp.pinpoint.grpc.trace.PActiveTraceHistogram)1 PAgentStatBatch (com.navercorp.pinpoint.grpc.trace.PAgentStatBatch)1 PCpuLoad (com.navercorp.pinpoint.grpc.trace.PCpuLoad)1 PCustomMetricMessage (com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage)1 PDataSourceList (com.navercorp.pinpoint.grpc.trace.PDataSourceList)1 PDirectBuffer (com.navercorp.pinpoint.grpc.trace.PDirectBuffer)1 PFileDescriptor (com.navercorp.pinpoint.grpc.trace.PFileDescriptor)1 PJvmGc (com.navercorp.pinpoint.grpc.trace.PJvmGc)1 PLoadedClass (com.navercorp.pinpoint.grpc.trace.PLoadedClass)1 PResponseTime (com.navercorp.pinpoint.grpc.trace.PResponseTime)1 PTotalThread (com.navercorp.pinpoint.grpc.trace.PTotalThread)1