Skip to content

Commit

Permalink
contrib/google.golang.org/grpc: Reduce allocs in interceptor (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanj committed Mar 8, 2022
1 parent 7d066c1 commit 7c11ba8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions contrib/google.golang.org/grpc/grpc.go
Expand Up @@ -48,11 +48,15 @@ func finishWithError(span ddtrace.Span, err error, cfg *config) {
err = nil
}
span.SetTag(tagCode, errcode.String())
finishOptions := []tracer.FinishOption{
tracer.WithError(err),
}
if cfg.noDebugStack {
finishOptions = append(finishOptions, tracer.NoDebugStack())

// only allocate finishOptions if needed, and allocate the exact right size
var finishOptions []tracer.FinishOption
if err != nil {
if cfg.noDebugStack {
finishOptions = []tracer.FinishOption{tracer.WithError(err), tracer.NoDebugStack()}
} else {
finishOptions = []tracer.FinishOption{tracer.WithError(err)}
}
}
span.Finish(finishOptions...)
}

0 comments on commit 7c11ba8

Please sign in to comment.