nrsql

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 6 Imported by: 0

README

nrsql

GoDoc

SQL database driver wrapper with New Relic instrumentation for Go.

Usage

driver := &pq.Driver{}
driver = nrsql.Wrap(
	driver,
	nrsql.WithDBName("foobar"),
	nrsql.WithDatastore(newrelic.DatastorePostgres),
)
sql.Register("foobar-postgres", driver)

db, err := sql.Open("foobar-postgres", databaseURL)
// ...

Author

License

licensed under the MIT License. See LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(d driver.Driver, opts ...Option) driver.Driver

Wrap returns a wrapped Driver with New Relic insturmentaiton.

Types

type Config

type Config struct {
	Datastore    newrelic.DatastoreProduct
	DBName       string
	Host         string
	PortPathOrID string
}

Config contains metadata to send to New Relic.

type Option

type Option func(*Config)

Option configures a Config object.

func WithDBName

func WithDBName(dbName string) Option

WithDBName sets a DB name.

func WithDatastore

func WithDatastore(d newrelic.DatastoreProduct) Option

WithDatastore sets a datestore type.

func WithHost

func WithHost(host string) Option

WithHost sets a DB host.

func WithPortPathOrID

func WithPortPathOrID(v string) Option

WithPortPathOrID sets a DB port, path or id.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL