From 5433f3b003b6b3a929402b5a6a5d101cd7c6e48b Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 27 Apr 2020 09:49:42 +0800 Subject: [PATCH] Adds note about status cause --- .../grpc/src/main/java/brave/grpc/GrpcParser.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/instrumentation/grpc/src/main/java/brave/grpc/GrpcParser.java b/instrumentation/grpc/src/main/java/brave/grpc/GrpcParser.java index 95b02fd94a..af3a431d0d 100644 --- a/instrumentation/grpc/src/main/java/brave/grpc/GrpcParser.java +++ b/instrumentation/grpc/src/main/java/brave/grpc/GrpcParser.java @@ -14,6 +14,7 @@ package brave.grpc; import brave.ErrorParser; +import brave.Span; import brave.SpanCustomizer; import brave.Tracing; import brave.internal.Nullable; @@ -50,19 +51,18 @@ protected String spanName(MethodDescriptor methodDesc /** * Override to change what data from the status or trailers are parsed into the span modeling it. - * By default, this tags "grpc.status_code" when it is not OK. + * By default, this tags "grpc.status_code" when it is not OK, and "error" if there was no {@link + * Status#getCause()}. + * + *

Note: {@link Status#getCause()} will be set as {@link Span#error(Throwable)} by + * default. You don't need to parse it here. */ protected void onClose(Status status, Metadata trailers, SpanCustomizer span) { if (status == null || status.isOk()) return; String code = String.valueOf(status.getCode()); span.tag("grpc.status_code", code); - Throwable cause = status.getCause(); - if (cause != null) { - errorParser().error(status.getCause(), span); - } else { - span.tag("error", code); - } + if (status.getCause() == null) span.tag("error", code); } static @Nullable String method(String fullMethodName) {