Skip to content

Commit

Permalink
tracer: check for invalid reflection before checking is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgajg1134 committed Jun 12, 2023
1 parent ca97dad commit a58099a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ddtrace/tracer/option.go
Expand Up @@ -893,7 +893,11 @@ func FinishTime(t time.Time) FinishOption {
// err to set tags such as the error message, error type and stack trace. It has
// no effect if the error is nil.
func WithError(err error) FinishOption {
if err == nil || reflect.ValueOf(err).IsNil() {
if err == nil {
return func(_ *ddtrace.FinishConfig) {}
}
v := reflect.ValueOf(err)
if !v.IsValid() || v.IsNil() {
return func(_ *ddtrace.FinishConfig) {}
}
return func(cfg *ddtrace.FinishConfig) {
Expand Down

0 comments on commit a58099a

Please sign in to comment.