Search in sources :

Example 1 with PStatMessage

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

the class StatClientMock method agentStatBatch.

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

Example 2 with PStatMessage

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

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

Aggregations

PStatMessage (com.navercorp.pinpoint.grpc.trace.PStatMessage)3 Empty (com.google.protobuf.Empty)2 PAgentStat (com.navercorp.pinpoint.grpc.trace.PAgentStat)2 StatusError (com.navercorp.pinpoint.grpc.StatusError)1 PAgentStatBatch (com.navercorp.pinpoint.grpc.trace.PAgentStatBatch)1 PAgentUriStat (com.navercorp.pinpoint.grpc.trace.PAgentUriStat)1 DefaultMessage (com.navercorp.pinpoint.io.request.DefaultMessage)1 Message (com.navercorp.pinpoint.io.request.Message)1 StreamObserver (io.grpc.stub.StreamObserver)1