Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/google.golang.org/grpc: Reduce allocs in interceptor #1183

Merged
merged 2 commits into from Mar 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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...)
}