Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 1.03 KB

README.md

File metadata and controls

39 lines (28 loc) · 1.03 KB

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

Install

go get -u github.com/rafaelhl/gorm-newrelic-telemetry-plugin

Quick Start

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)