Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 835 Bytes

README.md

File metadata and controls

37 lines (25 loc) · 835 Bytes

Go Reference

otelpgx

Provides OpenTelemetry instrumentation for the jackc/pgx library.

Requirements

  • go 1.18 (or higher)
  • pgx v5 (or higher)

Usage

Install the library:

go get github.com/exaring/otelpgx

Create the tracer as part of your connection:

cfg, err := pgxpool.ParseConfig(connString)
if err != nil {
    return nil, fmt.Errorf("create connection pool: %w", err)
}

cfg.ConnConfig.Tracer = otelpgx.NewTracer()

conn, err := pgxpool.NewWithConfig(ctx, cfg)
if err != nil {
    return nil, fmt.Errorf("connect to database: %w", err)
}

See options.go for the full list of options.