GORM NewRelic Telemetry Plugin

A plugin to allow telemetry by NewRelic Go Agent for GORM

Overview

Plugin implementation to add datastore segments on a Newrelic transaction injected on Go application context.

Requirements

  • NewRelic Go Agent v3
  • Injected newrelic transaction on context of the app
  • Use WithContext function from gorm.DB passing the context with the transaction

How to use

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)

GitHub

View Github