apm-agent-go: github.com/elastic/apm-agent-go/module/apmgorm Index | Files | Directories

package apmgorm

import "github.com/elastic/apm-agent-go/module/apmgorm"

Package apmgorm provides wrappers for tracing GORM operations.


Package Files

context.go doc.go open.go

func Open Uses

func Open(dialect string, args ...interface{}) (*gorm.DB, error)

Open returns a *gorm.DB for the given dialect and arguments. The returned *gorm.DB will have callbacks registered with RegisterCallbacks, such that CRUD operations will be reported as spans.

Open accepts the following signatures:

- a datasource name (i.e. the second argument to sql.Open)
- a driver name and a datasource name
- a *sql.DB, or some other type with the same interface

If a driver and datasource name are supplied, and the appropriate apmgorm/dialects package has been imported (or the driver has otherwise been registered with apmsql), then the datasource name will be parsed for inclusion in the span context.

func RegisterCallbacks Uses

func RegisterCallbacks(db *gorm.DB)

RegisterCallbacks registers callbacks on db for reporting spans to Elastic APM. This is called automatically by apmgorm.Open; it is provided for cases where a *gorm.DB is acquired by other means.

func WithContext Uses

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

WithContext returns a copy of db with ctx recorded for use by the callbacks registered via RegisterCallbacks.


dialects/mysqlPackage apmgormmysql imports the gorm mysql dialect package, and also registers the mysql driver with apmsql.
dialects/postgresPackage apmgormpostgres imports the gorm postgres dialect package, and also registers the lib/pq driver with apmsql.
dialects/sqlitePackage apmgormsqlite imports the gorm sqlite dialect package, and also registers the sqlite3 driver with apmsql.

Package apmgorm imports 7 packages (graph). Updated 2020-06-30. Refresh now. Tools for package owners.