Search in sources :

Example 1 with StatusError

use of com.navercorp.pinpoint.grpc.StatusError in project pinpoint by naver.

the class ResponseStreamObserver method onError.

@Override
public void onError(Throwable t) {
    final StatusError statusError = StatusErrors.throwable(t);
    if (statusError.isSimpleError()) {
        logger.info("Failed to stream, name={}, cause={}", listener, statusError.getMessage());
    } else {
        logger.info("Failed to stream, name={}, cause={}", listener, statusError.getMessage(), statusError.getThrowable());
    }
    listener.onError(t);
}
Also used : StatusError(com.navercorp.pinpoint.grpc.StatusError)

Example 2 with StatusError

use of com.navercorp.pinpoint.grpc.StatusError in project pinpoint by naver.

the class GrpcCommandService method handleOnError.

private void handleOnError(Throwable t, PinpointGrpcServer pinpointGrpcServer, AgentInfo agentInfo) {
    Objects.requireNonNull(pinpointGrpcServer, "pinpointGrpcServer");
    Objects.requireNonNull(agentInfo, "agentInfo");
    final StatusError statusError = StatusErrors.throwable(t);
    if (statusError.isSimpleError()) {
        logger.info("Failed to command stream, {} => local, cause={}", agentInfo.getAgentKey(), statusError.getMessage());
    } else {
        logger.warn("Failed to command stream, {} => local, cause={}", agentInfo.getAgentKey(), statusError.getMessage(), statusError.getThrowable());
    }
    pinpointGrpcServer.disconnected();
}
Also used : StatusError(com.navercorp.pinpoint.grpc.StatusError)

Example 3 with StatusError

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

use of com.navercorp.pinpoint.grpc.StatusError in project pinpoint by naver.

the class RetryResponseStreamObserver method onError.

@Override
public void onError(Throwable throwable) {
    final StatusError statusError = StatusErrors.throwable(throwable);
    if (statusError.isSimpleError()) {
        logger.info("Error. request={}, cause={}", logString(message), statusError.getMessage());
    } else {
        logger.info("Error. request={}, cause={}", logString(message), statusError.getMessage(), statusError.getThrowable());
    }
    // Retry
    final int remainingRetryCount = nextRetryCount();
    retryScheduler.scheduleNextRetry(message, remainingRetryCount);
}
Also used : StatusError(com.navercorp.pinpoint.grpc.StatusError)

Example 5 with StatusError

use of com.navercorp.pinpoint.grpc.StatusError in project pinpoint by naver.

the class SpanService method sendSpan.

@Override
public StreamObserver<PSpanMessage> sendSpan(final StreamObserver<Empty> responseObserver) {
    StreamObserver<PSpanMessage> observer = new StreamObserver<PSpanMessage>() {

        @Override
        public void onNext(PSpanMessage spanMessage) {
            if (isDebug) {
                logger.debug("Send PSpan={}", MessageFormatUtils.debugLog(spanMessage));
            }
            if (spanMessage.hasSpan()) {
                final Message<PSpan> message = newMessage(spanMessage.getSpan(), DefaultTBaseLocator.SPAN);
                send(message, responseObserver);
            } else if (spanMessage.hasSpanChunk()) {
                final Message<PSpanChunk> message = newMessage(spanMessage.getSpanChunk(), DefaultTBaseLocator.SPANCHUNK);
                send(message, responseObserver);
            } else {
                if (isDebug) {
                    logger.debug("Found empty span message {}", MessageFormatUtils.debugLog(spanMessage));
                }
            }
        }

        @Override
        public void onError(Throwable throwable) {
            com.navercorp.pinpoint.grpc.Header header = ServerContext.getAgentInfo();
            final StatusError statusError = StatusErrors.throwable(throwable);
            if (statusError.isSimpleError()) {
                logger.info("Failed to span stream, {} cause={}", header, statusError.getMessage(), statusError.getThrowable());
            } else {
                logger.warn("Failed to span stream, {} cause={}", header, statusError.getMessage(), statusError.getThrowable());
            }
        }

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

Aggregations

StatusError (com.navercorp.pinpoint.grpc.StatusError)6 StreamObserver (io.grpc.stub.StreamObserver)3 DefaultMessage (com.navercorp.pinpoint.io.request.DefaultMessage)2 Message (com.navercorp.pinpoint.io.request.Message)2 Empty (com.google.protobuf.Empty)1 PAgentStat (com.navercorp.pinpoint.grpc.trace.PAgentStat)1 PAgentUriStat (com.navercorp.pinpoint.grpc.trace.PAgentUriStat)1 PPing (com.navercorp.pinpoint.grpc.trace.PPing)1 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)1 PSpanMessage (com.navercorp.pinpoint.grpc.trace.PSpanMessage)1 PStatMessage (com.navercorp.pinpoint.grpc.trace.PStatMessage)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1