blob: 8282bd758467690aba93c9fb8d794e0ce403ac5f [file] [log] [blame]
David K. Bainbridgebd6b2882021-08-26 13:31:02 +00001package ext
2
3import (
4 "github.com/opentracing/opentracing-go"
5 "github.com/opentracing/opentracing-go/log"
6)
7
8// LogError sets the error=true tag on the Span and logs err as an "error" event.
9func LogError(span opentracing.Span, err error, fields ...log.Field) {
10 Error.Set(span, true)
11 ef := []log.Field{
12 log.Event("error"),
13 log.Error(err),
14 }
15 ef = append(ef, fields...)
16 span.LogFields(ef...)
17}