Search in sources :

Example 1 with PAgentUriStat

use of com.navercorp.pinpoint.grpc.trace.PAgentUriStat 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 2 with PAgentUriStat

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

the class GrpcUriStatMessageConverterTest method convertTest.

@Test
public void convertTest() {
    long currentTimeMillis = System.currentTimeMillis();
    AgentUriStatData agentUriStatData = new AgentUriStatData(currentTimeMillis);
    List<UriStatInfo> uriStatInfoList = createRandomUriStatInfo(100);
    for (UriStatInfo uriStatInfo : uriStatInfoList) {
        agentUriStatData.add(uriStatInfo);
    }
    GrpcUriStatMessageConverter converter = new GrpcUriStatMessageConverter();
    PAgentUriStat agentUriStat = converter.toMessage(agentUriStatData);
    List<PEachUriStat> eachUriStatList = agentUriStat.getEachUriStatList();
    assertData(uriStatInfoList, eachUriStatList);
}
Also used : AgentUriStatData(com.navercorp.pinpoint.profiler.monitor.metric.uri.AgentUriStatData) PAgentUriStat(com.navercorp.pinpoint.grpc.trace.PAgentUriStat) PEachUriStat(com.navercorp.pinpoint.grpc.trace.PEachUriStat) UriStatInfo(com.navercorp.pinpoint.profiler.monitor.metric.uri.UriStatInfo) Test(org.junit.Test)

Example 3 with PAgentUriStat

use of com.navercorp.pinpoint.grpc.trace.PAgentUriStat 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 PAgentUriStat

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

the class GrpcUriStatMessageConverter method createPAgentUriStat.

private PAgentUriStat createPAgentUriStat(AgentUriStatData agentUriStatData) {
    long baseTimestamp = agentUriStatData.getBaseTimestamp();
    PAgentUriStat.Builder builder = PAgentUriStat.newBuilder();
    builder.setTimestamp(baseTimestamp);
    builder.setBucketVersion(UriStatHistogramBucket.getBucketVersion());
    Collection<EachUriStatData> allUriStatData = agentUriStatData.getAllUriStatData();
    for (EachUriStatData eachUriStatData : allUriStatData) {
        PEachUriStat pEachUriStat = createPEachUriStat(eachUriStatData);
        builder.addEachUriStat(pEachUriStat);
    }
    return builder.build();
}
Also used : PAgentUriStat(com.navercorp.pinpoint.grpc.trace.PAgentUriStat) PEachUriStat(com.navercorp.pinpoint.grpc.trace.PEachUriStat) EachUriStatData(com.navercorp.pinpoint.profiler.monitor.metric.uri.EachUriStatData)

Example 5 with PAgentUriStat

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

the class GrpcAgentUriStatHandlerV2Test method handleTest.

@Test
public void handleTest() {
    AgentUriStatService mockAgentUriStatService = Mockito.mock(AgentUriStatService.class);
    attachContext(new Header("name", "agentId", "agentName", "applicationName", ServiceType.UNKNOWN.getCode(), System.currentTimeMillis(), Header.SOCKET_ID_NOT_EXIST, new ArrayList<>()));
    PAgentUriStat pAgentUriStat = createPAgentUriStat();
    ServerRequest<GeneratedMessageV3> mockServerRequest = Mockito.mock(ServerRequest.class);
    Mockito.when(mockServerRequest.getData()).thenReturn(pAgentUriStat);
    GrpcAgentStatHandlerV2 handler = createMockHandler(mockAgentUriStatService, true);
    handler.handleSimple(mockServerRequest);
    Mockito.verify(mockAgentUriStatService, times(1)).save(Mockito.any());
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) AgentUriStatService(com.navercorp.pinpoint.collector.service.AgentUriStatService) ArrayList(java.util.ArrayList) PAgentUriStat(com.navercorp.pinpoint.grpc.trace.PAgentUriStat) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

PAgentUriStat (com.navercorp.pinpoint.grpc.trace.PAgentUriStat)5 PAgentStat (com.navercorp.pinpoint.grpc.trace.PAgentStat)2 PEachUriStat (com.navercorp.pinpoint.grpc.trace.PEachUriStat)2 AgentUriStatData (com.navercorp.pinpoint.profiler.monitor.metric.uri.AgentUriStatData)2 Test (org.junit.Test)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 AgentUriStatService (com.navercorp.pinpoint.collector.service.AgentUriStatService)1 Header (com.navercorp.pinpoint.grpc.Header)1 StatusError (com.navercorp.pinpoint.grpc.StatusError)1 PAgentStatBatch (com.navercorp.pinpoint.grpc.trace.PAgentStatBatch)1 PCustomMetricMessage (com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage)1 PStatMessage (com.navercorp.pinpoint.grpc.trace.PStatMessage)1 DefaultMessage (com.navercorp.pinpoint.io.request.DefaultMessage)1 Message (com.navercorp.pinpoint.io.request.Message)1 AgentCustomMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch)1 AgentStatMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot)1 AgentStatMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch)1 EachUriStatData (com.navercorp.pinpoint.profiler.monitor.metric.uri.EachUriStatData)1 UriStatInfo (com.navercorp.pinpoint.profiler.monitor.metric.uri.UriStatInfo)1 StreamObserver (io.grpc.stub.StreamObserver)1