apm-agent-go: github.com/elastic/apm-agent-go/module/apmsql Index | Files | Directories

package apmsql

import "github.com/elastic/apm-agent-go/module/apmsql"

Package apmsql provides wrappers for tracing SQL query spans.

Index

Package Files

conn.go conn_go110.go conn_pre_go115.go doc.go driver.go driver_go110.go dsn.go signature.go stmt.go utils.go

Constants

const DriverPrefix = "apm/"

DriverPrefix should be used as a driver name prefix when registering via sql.Register.

func Open Uses

func Open(driverName, dataSourceName string) (*sql.DB, error)

Open opens a database with the given driver and data source names, as in sql.Open. The driver name should be one registered via the Register function in this package.

func QuerySignature Uses

func QuerySignature(query string) string

QuerySignature returns the "signature" for a query: a high level description of the operation.

For DDL statements (CREATE, DROP, ALTER, etc.), we we only report the first keyword, on the grounds that these statements are not expected to be common within the hot code paths of an application. For SELECT, INSERT, and UPDATE, and DELETE, we attempt to extract the first table name. If we are unable to identify the table name, we simply omit it.

func Register Uses

func Register(name string, driver driver.Driver, opts ...WrapOption)

Register registers a traced version of the given driver.

The name and driver values should be the same as given to sql.Register: the name of the driver (e.g. "postgres"), and the driver (e.g. &github.com/lib/pq.Driver{}).

func Wrap Uses

func Wrap(driver driver.Driver, opts ...WrapOption) driver.Driver

Wrap wraps a database/sql/driver.Driver such that the driver's database methods are traced. The tracer will be obtained from the context supplied to methods that accept it.

type DSNInfo Uses

type DSNInfo struct {
    // Address is the database server address specified by the DSN.
    Address string

    // Port is the database server port specified by the DSN.
    Port int

    // Database is the name of the specific database identified by the DSN.
    Database string

    // User is the username that the DSN specifies for authenticating the
    // database connection.
    User string
}

DSNInfo contains information from a database-specific data source name.

type DSNParserFunc Uses

type DSNParserFunc func(dsn string) DSNInfo

DSNParserFunc is the type of a function that can be used for parsing a data source name, and returning the corresponding Info.

func DriverDSNParser Uses

func DriverDSNParser(driverName string) DSNParserFunc

DriverDSNParser returns the DSNParserFunc for the registered driver. If there is no such registered driver, the parser function that is returned will return empty DSNInfo structures.

type WrapOption Uses

type WrapOption func(*tracingDriver)

WrapOption is an option that can be supplied to Wrap.

func WithDSNParser Uses

func WithDSNParser(f DSNParserFunc) WrapOption

WithDSNParser returns a WrapOption which sets the function to use for parsing the data source name. If WithDSNParser is not supplied to Wrap, the function to use will be inferred from the driver name.

func WithDriverName Uses

func WithDriverName(name string) WrapOption

WithDriverName returns a WrapOption which sets the underlying driver name to the specified value. If WithDriverName is not supplied to Wrap, the driver name will be inferred from the driver supplied to Wrap.

Directories

PathSynopsis
mysqlPackage apmmysql registers the "mysql" driver with apmsql, so that you can trace go-sql-driver/mysql database connections.
pqPackage apmpq registers the "postgres" driver with apmsql, so that you can trace lib/pq database connections.
sqlite3Package apmsqlite3 registers the "sqlite3" driver with apmsql, so that you can trace sqlite3 database connections.

Package apmsql imports 10 packages (graph). Updated 2020-08-07. Refresh now. Tools for package owners.