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/gorm.io/gorm.v1: Add err check #940

Merged
merged 11 commits into from
Oct 20, 2021
Merged

contrib/gorm.io/gorm.v1: Add err check #940

merged 11 commits into from
Oct 20, 2021

Conversation

vmlellis
Copy link
Contributor

Add WithErrorCheck option.

An implementation of #915

@songtianyi
Copy link

When will this PR be merged, it's very usefull

Copy link
Member

@felixge felixge left a comment

Choose a reason for hiding this comment

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

👋 @vmlellis sorry for the delay on this. I work on the profiler, but I just took a quick look to see if I can help getting this unstuck. PTAL at my comments, addressing them should help with getting this merged.

contrib/gorm.io/gorm.v1/gorm_test.go Show resolved Hide resolved
span.Finish(tracer.WithError(db.Error))
defer span.Finish()
if cfg.errCheck(db.Error) {
span.SetTag(ext.Error, db.Error)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for using SetTag() instead of tracer.WithError() here? If not, the latter would probably be preferable as it reduces the burden on the reviewer to verify that the two are interchangable.

Choose a reason for hiding this comment

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

@felixge Maybe there ref

span.SetTag(ext.Error, scope.DB().Error)

Copy link
Contributor Author

@vmlellis vmlellis Sep 3, 2021

Choose a reason for hiding this comment

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

I changed to this:

	var dbErr error
	if cfg.errCheck(db.Error) {
		dbErr = db.Error
	}
	span.Finish(tracer.WithError(dbErr))

@knusbaum knusbaum added this to the Triage milestone Aug 9, 2021
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

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

I have a few comments.

contrib/gorm.io/gorm.v1/gorm_test.go Outdated Show resolved Hide resolved
contrib/gorm.io/gorm.v1/gorm_test.go Outdated Show resolved Hide resolved
contrib/gorm.io/gorm.v1/gorm_test.go Outdated Show resolved Hide resolved
contrib/gorm.io/gorm.v1/gorm_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

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

LGTM

@freehere107
Copy link

@felixge Hi, Can you help to take a look at this or? At present, datadog will record db record not found, which is troublesome to use

@knusbaum knusbaum dismissed felixge’s stale review September 27, 2021 18:38

Comments were addressed.

@knusbaum knusbaum modified the milestones: Triage, 1.34.0 Sep 27, 2021
knusbaum
knusbaum previously approved these changes Sep 27, 2021
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

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

Sorry it took a while to get back to this.
There is one nitpick I have and then I will merge this.

contrib/gorm.io/gorm.v1/option.go Outdated Show resolved Hide resolved
Co-authored-by: Kyle Nusbaum <kyle.nusbaum@datadoghq.com>
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'm approving & merging, since I see it was thoroughly reviewed by @knusbaum and @felixge with all comments addressed.

@gbbr gbbr merged commit 45529e2 into DataDog:v1 Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants