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

ddtrace/tracer: add NoDebugStack finishing option #355

Merged
merged 8 commits into from
Nov 4, 2018
Merged

Conversation

niamster
Copy link
Contributor

@niamster niamster commented Oct 30, 2018

Traceback generation in Go is quite costly operation and as errors such as BE is throttled might occur very often the the application end up just burning CPU on generating the backtraces.

On top of that the gRPC backtraces are super long which put pressure on GC and also they are completely useless as they all end up in gRPC's stack not pointing to a caller

Address #354

@gbbr
Copy link
Contributor

gbbr commented Oct 30, 2018

The purpose of opening an issue before a PR is to first discuss a solution before writing code. Let’s figure out how we’ll implement this and then come back to writing code. I hope that’s ok with you.

@gbbr gbbr closed this Oct 30, 2018
@gbbr gbbr deleted the dm/optional-trace-back branch October 30, 2018 21:46
@niamster
Copy link
Contributor Author

@gbbr why did you close the PR? This way you discourage people fixing issues

@niamster
Copy link
Contributor Author

Just for you reference I can't reopen this PR

@gbbr gbbr restored the dm/optional-trace-back branch November 2, 2018 09:56
@gbbr
Copy link
Contributor

gbbr commented Nov 2, 2018

@gbbr why did you close the PR? This way you discourage people fixing issues

I apologize for not replying earlier, for some reason I did not get any notification from Github that you have written these messages. My intention is in no way to discourage you or anyone from submitting changes to the repository. I also apologize if my comment was too brief. The reason I have closed it is because of our contribution guidelines (here) where the first paragraph says:

Pull requests for bug fixes are welcome, but before submitting new features or changes to current functionalities open an issue and discuss your ideas or propose the changes you wish to make. After a resolution is reached a PR can be submitted for review.

This is normal open-source workflow and is nothing specific to our project or out of the ordinary. Our contribution guidelines file is also standard for Github and a link to it is presented when opening a Pull Request. I am sorry if you were not aware of this. My intention was in no way to make you feel like your work was rejected. I was simply saying that we should go back to discussing it before writing code and follow the same workflow as everyone else. Perhaps closing the PR gave you the wrong impression.

Just for you reference I can't reopen this PR

You can if you push your local copy of the branch. I have also restored the remote branch for you, if we will have to reopen it.

For future reference, I'd recommend reading Github's "Open Source Guide". It provides a lot of useful information about how to contribute to open source projects.

I hope you are still willing to discuss a solution to this in the issue and reach a consensus together. I'd be happy if you'd re-open your PR and make the changes we agree on, after we agree on them on the linked issue.

@gbbr
Copy link
Contributor

gbbr commented Nov 2, 2018

Re-opening as per discussion in #354

@gbbr gbbr reopened this Nov 2, 2018
ddtrace/tracer/option.go Outdated Show resolved Hide resolved
@@ -161,3 +161,10 @@ func WithError(err error) FinishOption {
cfg.Error = err
}
}

// Disable backtrace generation in case of error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll have to phrase this starting the name of the identifier, otherwise it's not standard and the linter will warn you:

// NoDebugStack prevents any error presented using the WithError finishing option
// from generating a stack trace. This is useful in situations where errors are frequent
// and performance is critical.

ddtrace/tracer/span.go Outdated Show resolved Hide resolved
ddtrace/tracer/span.go Show resolved Hide resolved
ddtrace/tracer/span.go Show resolved Hide resolved
contrib/google.golang.org/grpc/grpc.go Outdated Show resolved Hide resolved
ddtrace/tracer/span_test.go Outdated Show resolved Hide resolved
@niamster
Copy link
Contributor Author

niamster commented Nov 2, 2018

CI is failing with an unrelated to this PR error:

package github.com/mongodb/mongo-go-driver/mongo/clientopt: cannot find package "github.com/mongodb/mongo-go-driver/mongo/clientopt" in any of:
	/usr/local/go/src/github.com/mongodb/mongo-go-driver/mongo/clientopt (from $GOROOT)
	/go/src/github.com/mongodb/mongo-go-driver/mongo/clientopt (from $GOPATH)

@gbbr do you have a fix for that?

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your current implementation and solution is perfect, but please use the exact wording suggested for the documentation.

ddtrace/tracer/span.go Show resolved Hide resolved
ddtrace/ddtrace.go Outdated Show resolved Hide resolved
ddtrace/tracer/option.go Outdated Show resolved Hide resolved
contrib/google.golang.org/grpc/option.go Outdated Show resolved Hide resolved
finishOptions := []tracer.FinishOption{
tracer.WithError(err),
}
if noDebugStack {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gbbr gbbr changed the title disable backtrace generation for gRPC ddtrace/tracer: add NoDebugStack finishing option Nov 4, 2018
@gbbr gbbr added this to the 1.5.0 milestone Nov 4, 2018
@gbbr gbbr added the apm:ecosystem contrib/* related feature requests or bugs label Nov 4, 2018
@gbbr
Copy link
Contributor

gbbr commented Nov 4, 2018

CI is failing with an unrelated to this PR error

I will resolve this. We should maybe remove support for this library. They are making breaking changes every week.

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added another commit fixing CI and some comments of mine that you've missed (you didn't follow the exact wording I've suggested and you forgot to remove the breaking change from grpc.v12).

@gbbr gbbr merged commit 48eeff2 into v1 Nov 4, 2018
@gbbr gbbr deleted the dm/optional-trace-back branch November 4, 2018 15:49
@gbbr
Copy link
Contributor

gbbr commented Nov 4, 2018

Thanks! Will include this in the release this following week!

@niamster
Copy link
Contributor Author

niamster commented Nov 4, 2018

Thanks @gbbr Indeed I've forgotten to remove the code I've added for grpc.v12.

mingrammer pushed a commit to mingrammer/dd-trace-go that referenced this pull request Dec 22, 2020
Adds a new finish option to the tracer which does not cause the generation of a stack trace on errors for performance reasons in some scenarios.

Additionally, it adds this as opt-in to the grpc integration.

Fixes DataDog#354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants