nrpgx

package module
Version: v0.0.0-...-02734b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 12 Imported by: 0

README

nrpgx

Unofficial New Relic jackc/pgx integration. Use at your own risk

Ported from https://github.com/newrelic/go-agent/tree/master/v3/integrations/nrpq.

Usage

// 1. Use this package's driver in place of the postgres driver.
//
// If your code is using sql.Open like this:
//
//	import (
//		_ "github.com/jackc/pgx/v4/stdlib"
//	)
//
//	func main() {
//		db, err := sql.Open("pgx", "user=pqgotest dbname=pqgotest sslmode=verify-full")
//	}
//
// Then change the side-effect import to this package, and open "nrpgx" instead:
//
//	import (
//		_ "github.com/yulrizka/nrpgx"
//	)
//
//	func main() {
//		db, err := sql.Open("nrpgx", "user=pqgotest dbname=pqgotest sslmode=verify-full")
//	}
//
// Make sure you pass along the Context object when doing the query (eg. ExecContext, QueryContext)

Documentation

Overview

Package nrpgx instruments https://github.com/jackc/pgx.

Use this package to instrument your PostgreSQL calls without having to manually create DatastoreSegments. This is done in a two step process:

1. Use this package's driver in place of the postgres driver.

If your code is using sql.Open like this:

	import (
     _ "github.com/jackc/pgx/v4/stdlib"
	)

	func main() {
		db, err := sql.Open("pgx", "user=pqgotest dbname=pqgotest sslmode=verify-full")
	}

Then change the side-effect import to this package, and open "nrpgx" instead:

import (
	_ "github.com/yulrizka/nrpgx"
)

func main() {
	db, err := sql.Open("nrpgx", "user=pqgotest dbname=pqgotest sslmode=verify-full")
}

Make sure you pass along the Context object when doing the query (eg. ExecContext, QueryContext)

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL