package pgxtraces

Import Path
	go.pact.im/x/traces/pgxtraces (on go.dev)

Dependency Relation
	imports 8 packages, and imported by one package

Involved Source Files conn.go Package pgxtraces provides pgx v5 tracer instrumentation using [traces.Tracer]. query.go tracer.go
Code Examples package main import ( "context" "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/multitracer" "github.com/jackc/pgx/v5/tracelog" "go.pact.im/x/traces" "go.pact.im/x/traces/pgxtraces" ) func main() { tr := traces.New(traces.DiscardHandler()) cfg, _ := pgx.ParseConfig("postgres://localhost:5432/app") cfg.Tracer = multitracer.New( pgxtraces.New(tr), &tracelog.TraceLog{ Logger: tracelog.LoggerFunc(func(context.Context, tracelog.LogLevel, string, map[string]any) {}), LogLevel: tracelog.LogLevelWarn, }, ) _ = cfg }
Package-Level Type Names (total 7, in which 1 is exported)
/* sort exporteds by: | */
Tracer traces pgx v5 operations using [traces.Tracer]. It implements [pgx.QueryTracer], [pgx.BatchTracer], [pgx.CopyFromTracer], [pgx.PrepareTracer], [pgx.ConnectTracer], and [pgxpool.AcquireTracer]. Assign a Tracer to [pgx.ConnConfig.Tracer] (or pgxpool.Config.ConnConfig.Tracer). Query arguments are never recorded; SQL text is recorded in db.query.text by default and can be redacted or omitted via [Tracer.WithQueryText]. [pgx.ErrNoRows] is not marked as a span error. TraceAcquireEnd implements the [pgxpool.AcquireTracer] interface. TraceAcquireStart implements the [pgxpool.AcquireTracer] interface. TraceBatchEnd implements the [pgx.BatchTracer] interface. TraceBatchQuery implements the [pgx.BatchTracer] interface. It records a child span under the active batch span using data.ReadStartTime when available. TraceBatchStart implements the [pgx.BatchTracer] interface. TraceConnectEnd implements the [pgx.ConnectTracer] interface. TraceConnectStart implements the [pgx.ConnectTracer] interface. TraceCopyFromEnd implements the [pgx.CopyFromTracer] interface. TraceCopyFromStart implements the [pgx.CopyFromTracer] interface. TracePrepareEnd implements the [pgx.PrepareTracer] interface. TracePrepareStart implements the [pgx.PrepareTracer] interface. TraceQueryEnd implements the [pgx.QueryTracer] interface. TraceQueryStart implements the [pgx.QueryTracer] interface. WithAttrs returns a [Tracer] using f to attach additional start-time attributes for each operation. If f is nil, only default attributes are added. WithFilter returns a [Tracer] that only traces operations for which f returns true. The op argument is the uppercased SQL verb (such as "SELECT") or one of "BATCH", "COPY", "PREPARE", "CONNECT", or "ACQUIRE". If f is nil, all operations are traced. WithQueryText returns a [Tracer] using f to transform or filter SQL text before recording it in db.query.text. Returning ok == false omits db.query.text. If f is nil, it restores recording the SQL string as-is. WithSpanName returns a [Tracer] using f to compute the span name from the operation and database namespace. If f is nil, it restores the default "{op} {db}" naming. *Tracer : github.com/jackc/pgx/v5.BatchTracer *Tracer : github.com/jackc/pgx/v5.ConnectTracer *Tracer : github.com/jackc/pgx/v5.CopyFromTracer *Tracer : github.com/jackc/pgx/v5.PrepareTracer *Tracer : github.com/jackc/pgx/v5.QueryTracer *Tracer : github.com/jackc/pgx/v5/pgxpool.AcquireTracer func New(tr *traces.Tracer) *Tracer func (*Tracer).WithAttrs(f func(ctx context.Context) []traces.Attr) *Tracer func (*Tracer).WithFilter(f func(ctx context.Context, op string) bool) *Tracer func (*Tracer).WithQueryText(f func(sql string) (text string, ok bool)) *Tracer func (*Tracer).WithSpanName(f func(op, db string) string) *Tracer
Package-Level Functions (total 10, in which 1 is exported)
New returns a new [Tracer] instance using tr.
Package-Level Constants (total 18, none are exported)