github.com/prysmaticlabs/prysm@v1.4.4/shared/traceutil/errors.go (about) 1 // Package traceutil includes useful functions for opentracing annotations. 2 package traceutil 3 4 import ( 5 "go.opencensus.io/trace" 6 ) 7 8 // AnnotateError on span. This should be used any time a particular span experiences an error. 9 func AnnotateError(span *trace.Span, err error) { 10 if err == nil { 11 return 12 } 13 span.AddAttributes(trace.BoolAttribute("error", true)) 14 span.SetStatus(trace.Status{ 15 Code: trace.StatusCodeUnknown, 16 Message: err.Error(), 17 }) 18 }