Package gorm provides helper functions for tracing the jinzhu/gorm package (




    This section is empty.


    This section is empty.


    func ContextFromDB

    func ContextFromDB(db *gorm.DB) context.Context

      ContextFromDB returns any context previously attached to db using WithContext, otherwise returning context.Background.

      func Open

      func Open(dialect, source string, opts ...Option) (*gorm.DB, error)

        Open opens a new (traced) database connection. The used dialect must be formerly registered using (


        func WithCallbacks

        func WithCallbacks(db *gorm.DB, opts ...Option) *gorm.DB

          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.

          func WithContext

          func WithContext(ctx context.Context, db *gorm.DB) *gorm.DB

            WithContext attaches the specified context to the given db. The context will be used as a basis for creating new spans. An example use case is providing a context which contains a span to be used as a parent.


            type Option

            type Option func(*config)

              Option represents an option that can be passed to Register, Open or OpenDB.

              func WithAnalytics

              func WithAnalytics(on bool) Option

                WithAnalytics enables Trace Analytics for all started spans.

                func WithAnalyticsRate

                func WithAnalyticsRate(rate float64) Option

                  WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.

                  func WithCustomTag

                  func WithCustomTag(tag string, tagFn func(scope *gorm.Scope) interface{}) Option

                    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

                    func WithErrorCheck(fn func(err error) bool) Option

                      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

                      func WithServiceName

                      func WithServiceName(name string) Option

                        WithServiceName sets the given service name when registering a driver, or opening a database connection.

                        Source Files