Package gorm provides helper functions for tracing the jinzhu/gorm package (https://github.com/jinzhu/gorm).
- func ContextFromDB(db *gorm.DB) context.Context
- func Open(dialect, source string, opts ...Option) (*gorm.DB, error)
- func WithCallbacks(db *gorm.DB, opts ...Option) *gorm.DB
- func WithContext(ctx context.Context, db *gorm.DB) *gorm.DB
- type Option
func ContextFromDB ¶
ContextFromDB returns any context previously attached to db using WithContext, otherwise returning context.Background.
Open opens a new (traced) database connection. The used dialect must be formerly registered using (gopkg.in/DataDog/dd-trace-go.v1/contrib/database/sql).Register.
func WithCallbacks ¶
WithCallbacks registers callbacks to the gorm.DB for tracing. It should be called once, after opening the db. The callbacks are triggered by Create, Update, Delete, Query and RowQuery operations.
type Option func(*config)
Option represents an option that can be passed to Register, Open or OpenDB.
func WithAnalytics ¶
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithCustomTag ¶
WithCustomTag will cause the given tagFn to be evaluated after executing a query and attach the result to the span tagged by the key.
func WithErrorCheck ¶
WithErrorCheck specifies a function fn which determines whether the passed error should be marked as an error. The fn is called whenever a gorm operation finishes with an error