Documentation
¶
Overview ¶
Package hnysql wraps `database.sql` to emit one Honeycomb event per DB call.
After opening a DB connection, replace the *sql.DB object with a *hnysql.DB object. The *hnysql.DB struct implements all the same functions as the normal *sql.DB struct, and emits an event to Honeycomb with details about the SQL event made.
Additionally, if hnysql is used in conjunction with one of the Honeycomb HTTP wrappers *and* you use the context-aware version of the DB calls, the trace ID picked up in the HTTP event will appear in the SQL event to allow easy identification of what HTTP call triggers which SQL calls.
It is strongly suggested that you use the context-aware version of all calls whenever possible; doing so not only lets you cancel your database calls, but dramatically increases the value of the SQL isntrumentation by letting you tie it back to individual HTTP requests.
Example ¶
Output:
Index ¶
- type Conn
- func (c *Conn) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (c *Conn) Close() error
- func (c *Conn) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (c *Conn) PingContext(ctx context.Context) error
- func (c *Conn) PrepareContext(ctx context.Context, query string) (*Stmt, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (c *Conn) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- type DB
- func (db *DB) Begin() (*Tx, error)
- func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (db *DB) Close() error
- func (db *DB) Conn(ctx context.Context) (*Conn, error)
- func (db *DB) Driver() driver.Driver
- func (db *DB) Exec(query string, args ...interface{}) (sql.Result, error)
- func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (db *DB) Ping() error
- func (db *DB) PingContext(ctx context.Context) error
- func (db *DB) Prepare(query string) (*Stmt, error)
- func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error)
- func (db *DB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) QueryRow(query string, args ...interface{}) *sql.Row
- func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (db *DB) SetConnMaxLifetime(d time.Duration)
- func (db *DB) SetMaxIdleConns(n int)
- func (db *DB) SetMaxOpenConns(n int)
- func (db *DB) Stats() sql.DBStats
- type Stmt
- func (s *Stmt) Close() error
- func (s *Stmt) Exec(args ...interface{}) (sql.Result, error)
- func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)
- func (s *Stmt) Query(args ...interface{}) (*sql.Rows, error)
- func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error)
- func (s *Stmt) QueryRow(args ...interface{}) *sql.Row
- func (s *Stmt) QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row
- type Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (tx *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (tx *Tx) Prepare(query string) (*Stmt, error)
- func (tx *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error)
- func (tx *Tx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (tx *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (tx *Tx) QueryRow(query string, args ...interface{}) *sql.Row
- func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (tx *Tx) Rollback() error
- func (tx *Tx) Stmt(stmt *Stmt) *Stmt
- func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
func (*Conn) ExecContext ¶
func (*Conn) PrepareContext ¶
func (*Conn) QueryContext ¶
type DB ¶
type DB struct { // Builder is available in case you wish to add fields to every SQL event // that will be created. Builder *libhoney.Builder // contains filtered or unexported fields }