From 8e3a6e9fc84ea99461225f4070b30352be15ef62 Mon Sep 17 00:00:00 2001 From: jaehong-kim Date: Fri, 16 Sep 2022 10:45:11 +0900 Subject: [PATCH] [#9187] Fix span dispatch failed --- .../context/grpc/GrpcSpanMessageConverter.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/grpc/GrpcSpanMessageConverter.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/grpc/GrpcSpanMessageConverter.java index cf93ef91a0654..6e1430a87595f 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/grpc/GrpcSpanMessageConverter.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/grpc/GrpcSpanMessageConverter.java @@ -22,6 +22,7 @@ import com.navercorp.pinpoint.common.annotations.VisibleForTesting; import com.navercorp.pinpoint.common.util.CollectionUtils; import com.navercorp.pinpoint.common.util.IntStringValue; +import com.navercorp.pinpoint.common.util.StringUtils; import com.navercorp.pinpoint.grpc.trace.PAcceptEvent; import com.navercorp.pinpoint.grpc.trace.PAnnotation; import com.navercorp.pinpoint.grpc.trace.PAnnotationValue; @@ -58,6 +59,9 @@ * @author Woonduk Kang(emeroad) */ public class GrpcSpanMessageConverter implements MessageConverter { + public static final String DEFAULT_END_POINT = "UNKNOWN"; + public static final String DEFAULT_RPC_NAME = "UNKNOWN"; + public static final String DEFAULT_REMOTE_ADDRESS = "UNKNOWN"; private final String agentId; private final short applicationServiceType; @@ -170,10 +174,13 @@ private boolean isCompressedType(TraceId traceId) { private PAcceptEvent newAcceptEvent(Span span) { PAcceptEvent.Builder builder = PAcceptEvent.newBuilder(); - builder.setRemoteAddr(span.getRemoteAddr()); + final String remoteAddr = StringUtils.defaultIfEmpty(span.getRemoteAddr(), DEFAULT_REMOTE_ADDRESS); + builder.setRemoteAddr(remoteAddr); final Shared shared = span.getTraceRoot().getShared(); - builder.setRpc(shared.getRpcName()); - builder.setEndPoint(shared.getEndPoint()); + final String rpc = StringUtils.defaultIfEmpty(shared.getRpcName(), DEFAULT_RPC_NAME); + builder.setRpc(rpc); + final String endPoint = StringUtils.defaultIfEmpty(shared.getEndPoint(), DEFAULT_END_POINT); + builder.setEndPoint(endPoint); PParentInfo pParentInfo = newParentInfo(span); if (pParentInfo != null) {