A plugin to allow telemetry by NewRelic Go Agent for GORM
Plugin implementation to add datastore segments on a Newrelic transaction injected on Go application context.
- NewRelic Go Agent v3
- Injected newrelic transaction on context of the app
- Use
WithContext
function fromgorm.DB
passing the context with the transaction
go get -u github.com/rafaelhl/gorm-newrelic-telemetry-plugin
Since this plugin implements the interface Plugin, just follow the example below available on test file newrelic_test.go:
db := "sqlite.db"
gormDB, err := gorm.Open(sqlite.Open(db), &gorm.Config{})
if err != nil {
panic(err)
}
err := gormDB.Use(telemetry.NewNrTracer(db, "local", "SQLite"))
assert.NoError(t, err)
gormDB.WithContext(ctx).Create(newEntity)