prysm-pulse/shared/traceutil/errors.go

19 lines
459 B
Go
Raw Normal View History

// Package traceutil includes useful functions for opentracing annotations.
2019-09-29 18:48:55 +00:00
package traceutil
import (
"go.opencensus.io/trace"
)
// AnnotateError on span. This should be used any time a particular span experiences an error.
func AnnotateError(span *trace.Span, err error) {
if err == nil {
return
}
2019-09-29 18:48:55 +00:00
span.AddAttributes(trace.BoolAttribute("error", true))
span.SetStatus(trace.Status{
Code: trace.StatusCodeUnknown,
Message: err.Error(),
})
}