-
Notifications
You must be signed in to change notification settings - Fork 488
fix(contrib/gorm.io): allow resource name to be overridden by custom tags #3909
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
fix(contrib/gorm.io): allow resource name to be overridden by custom tags #3909
Conversation
darccio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, leaving to @rarguelloF the definitive approval. I wonder if this should be applied to other contribs with this behaviour.
f211614 to
a1a4af1
Compare
a1a4af1 to
4102032
Compare
|
@rarguelloF Would you mind if I asked for a review of this please? I would love to be able to override the resource name! Thanks for your consideration! |
rarguelloF
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes LGTM, but we should add a test for this change to ensure we don't introduce regressions in the future.
4102032 to
300e7ee
Compare
| func withCallbacks(db *gorm.DB, opts ...Option) (*gorm.DB, error) { | ||
| cfg := new(config) | ||
| defaults(cfg) | ||
| cfg := newConfigWithDefaults() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the defaults function was only ever used here with a new config, so I thought that this would be an improvement (so that I didn't need do duplicate two lines in my new unit test)
|
@rarguelloF I have pushed up a new change which includes a unit test!! 😄 Would you mind taking a look please? 🙏 |
|
Thanks!! @will-bem |
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
devflow unqueued this merge request: It did not become mergeable within the expected time |
300e7ee to
211549d
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
The expected merge time in
Tests failed on this commit cc1b798:
What to do next?
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Tests failed on this commit 4c56ce0:
What to do next?
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What does this PR do?
When using package github.com/DataDog/dd-trace-go/contrib/gorm.io/gorm.v1/v2, I want to override the resource name (because the SQL is long and unwieldy). Alas, I cannot do this with
gormtrace.WithCustomTag(ext.ResourceName, ...because thespan.SetTag(ext.ResourceName, db.Statement.SQL.String())call is done after processing custom tags. Thus, I propose moving the custom tag processing to below where the default resource name is set.Thank you for your consideration!