Documentation ¶
Overview ¶
Package atsql provides wrappers for tracing SQL query spans.
Index ¶
Constants ¶
const DriverPrefix = "apm/"
DriverPrefix should be used as a driver name prefix when registering via sql.Register.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
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 ¶
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 ¶
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{}).
Types ¶
type DSNInfo ¶
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 ¶
DSNParserFunc is the type of a function that can be used for parsing a data source name, and returning the corresponding Info.
func DriverDSNParser ¶
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 ¶
type WrapOption func(*tracingDriver)
WrapOption is an option that can be supplied to Wrap.
func WithDSNParser ¶
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 ¶
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
pgutil
Package pgutil provides utilities to postgres related modules.
|
Package pgutil provides utilities to postgres related modules. |
Package atmysql registers the "mysql" driver with atsql, so that you can trace go-sql-driver/mysql database connections.
|
Package atmysql registers the "mysql" driver with atsql, so that you can trace go-sql-driver/mysql database connections. |
Package atpq registers the "postgres" driver with atsql, so that you can trace lib/pq database connections.
|
Package atpq registers the "postgres" driver with atsql, so that you can trace lib/pq database connections. |
Package atsqlite3 registers the "sqlite3" driver with atsql, so that you can trace sqlite3 database connections.
|
Package atsqlite3 registers the "sqlite3" driver with atsql, so that you can trace sqlite3 database connections. |