Go Reference


Provides OpenTelemetry instrumentation for the jackc/pgx library.


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


Make sure you have a suitable pgx version:

go get github.com/jackc/pgx/v5

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.NewConfig(ctx, cfg)
if err != nil {
    return nil, fmt.Errorf("connect to database: %w", err)

See options.go for the full list of options.


View Github