Skip to content

Commit

Permalink
Merge pull request #297 from infobloxopen/FixForErrorSpan
Browse files Browse the repository at this point in the history
Tracing fixes for error span
  • Loading branch information
mphillips-infoblox authored Nov 23, 2021
2 parents 5b29119 + 506695c commit ee3a065
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tracing/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit ee3a065

Please sign in to comment.