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();
}
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;
}
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;
}
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();
}
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();
}
Aggregations