Documentation ¶
Overview ¶
Package sql provides functions to trace the database/sql package (https://golang.org/pkg/database/sql). It will automatically augment operations such as connections, statements and transactions with tracing.
We start by telling the package which driver we will be using. For example, if we are using "github.com/lib/pq", we would do as follows:
sqltrace.Register("pq", pq.Driver{}) db, err := sqltrace.Open("pq", "postgres://pqgotest:password@localhost...")
The rest of our application would continue as usual, but with tracing enabled.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open returns connection to a DB using a the traced version of the given driver. In order for Open to work, the driver must first be registered using Register or RegisterWithServiceName. If this did not occur, Open will return an error.
func Register ¶
func Register(driverName string, driver driver.Driver, opts ...RegisterOption)
Register tells the sql integration package about the driver that we will be tracing. It must be called before Open, if that connection is to be traced. It uses the driverName suffixed with ".db" as the default service name.
Types ¶
type RegisterOption ¶
type RegisterOption func(*registerConfig)
RegisterOption represents an option that can be passed to Register.
func WithAnalytics ¶
func WithAnalytics(on bool) RegisterOption
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
func WithAnalyticsRate(rate float64) RegisterOption
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithServiceName ¶
func WithServiceName(name string) RegisterOption
WithServiceName sets the given service name for the registered driver.