From 506695c9657521db1586213dbb18190648447c26 Mon Sep 17 00:00:00 2001 From: Mark Phillips Date: Thu, 18 Nov 2021 16:30:51 -0800 Subject: [PATCH] Tracing fixes for error span --- tracing/span.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tracing/span.go b/tracing/span.go index 04e07792..0a5559cc 100644 --- a/tracing/span.go +++ b/tracing/span.go @@ -78,16 +78,15 @@ func AddErrorCurrentSpan(ctx context.Context, err error) error { //AddErrorSpan adds error into span func AddErrorSpan(span *trace.Span, err error) error { - var code int32 = trace.StatusCodeUnknown + var code int32 = trace.StatusCodeOK status, ok := status.FromError(err) if ok && status != nil { code = int32(status.Code()) } - span.SetStatus(trace.Status{ - Code: code, - Message: err.Error(), - }) + if code != trace.StatusCodeOK { + span.AddAttributes(trace.Int64Attribute("census.status_code", int64(code)), trace.StringAttribute("census.status_description", err.Error()), trace.BoolAttribute("error", true)) + } return err }