-
Notifications
You must be signed in to change notification settings - Fork 45
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
Expose opentracing start span options to allow tag customization #110
Conversation
db.go
Outdated
// SetStartSpanOption will apply the span option function to every opentracing span created by squalor | ||
func SetStartSpanOption(spanOption opentracing.StartSpanOption) DBOption { | ||
return func(db *DB) error { | ||
if db.SpanOptions == nil { |
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.
You don't need the if
since append
will create the slice if needed
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.
You could also make this function take varargs ...opentracing.StartSpanOption
and append them all
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.
Good idea - fixed
db.go
Outdated
models map[reflect.Type]*Model | ||
mappings map[reflect.Type]fieldMap | ||
// Span option functions are applied to every span started by squalor, when OpentracingEnabled is true. | ||
SpanOptions []opentracing.StartSpanOption |
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.
Does this need to be visible (capitalized)?
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.
nope - made private
db.go
Outdated
@@ -513,6 +526,7 @@ func NewDB(db *sql.DB, options ...DBOption) (*DB, error) { | |||
IgnoreMissingCols: false, | |||
Logger: nil, | |||
OpentracingEnabled: false, | |||
SpanOptions: make([]opentracing.StartSpanOption, 0), |
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.
Could probably initialize to nil
just fine
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.
updated
5cd1a1b
to
51faa3a
Compare
Exposes the
opentracing.StartSpanOption
to allow callers to pass custom span tags. One use case is to allow control over Datadog's Unified Span Tagging. This is commonly done with database clients so that queries show as a different "service" in the Datadog interface, with their own Service Page that is tailored specifically to database interactions.