dbtrace

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package dbtrace provides OpenTelemetry tracing wrappers for database/sql operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB wraps *sql.DB with OpenTelemetry tracing.

func Wrap

func Wrap(db *sql.DB) *DB

Wrap creates a traced DB wrapper.

func (*DB) BeginTx

func (d *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTx starts a traced transaction.

func (*DB) Close

func (d *DB) Close() error

Close closes the underlying database connection.

func (*DB) DB

func (d *DB) DB() *sql.DB

DB exposes underlying *sql.DB.

func (*DB) ExecContext

func (d *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext traces ExecContext calls.

func (*DB) PrepareContext

func (d *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error)

PrepareContext prepares a traced statement.

func (*DB) QueryContext

func (d *DB) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext traces QueryContext calls.

func (*DB) QueryRowContext

func (d *DB) QueryRowContext(ctx context.Context, query string, args ...any) *Row

QueryRowContext traces QueryRowContext calls.

type Row

type Row struct {
	*sql.Row
	// contains filtered or unexported fields
}

Row wraps *sql.Row to terminate tracing span upon Scan.

func (*Row) Scan

func (r *Row) Scan(dest ...any) error

Scan scans row fields and completes trace span.

type Stmt

type Stmt struct {
	// contains filtered or unexported fields
}

Stmt represents a prepared traced database statement.

func (*Stmt) Close

func (s *Stmt) Close() error

Close closes the underlying prepared statement.

func (*Stmt) ExecContext

func (s *Stmt) ExecContext(ctx context.Context, args ...any) (sql.Result, error)

ExecContext executes a prepared statement with tracing.

func (*Stmt) QueryContext

func (s *Stmt) QueryContext(ctx context.Context, args ...any) (*sql.Rows, error)

QueryContext queries a prepared statement with tracing.

func (*Stmt) QueryRowContext

func (s *Stmt) QueryRowContext(ctx context.Context, args ...any) *Row

QueryRowContext queries a single row from a prepared statement with tracing.

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx wraps *sql.Tx with tracing.

func (*Tx) Commit

func (t *Tx) Commit() error

Commit commits transaction with tracing.

func (*Tx) ExecContext

func (t *Tx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext executes statement within transaction.

func (*Tx) QueryContext

func (t *Tx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext executes query within transaction.

func (*Tx) QueryRowContext

func (t *Tx) QueryRowContext(ctx context.Context, query string, args ...any) *Row

QueryRowContext executes single-row query within transaction.

func (*Tx) Rollback

func (t *Tx) Rollback() error

Rollback rolls back transaction with tracing.

func (*Tx) Tx

func (t *Tx) Tx() *sql.Tx

Tx exposes underlying *sql.Tx.

Jump to

Keyboard shortcuts

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