exaring/otelpgx

OpenTelemetry Tracing instrumentation for PostgreSQL

Go

228

79 commits

updated Oct 8, 2026

See the code

README

Go Reference

otelpgx

Provides OpenTelemetry instrumentation for the jackc/pgx library.

Requirements

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

Usage

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

if err := otelpgx.RecordStats(conn); err != nil {
    return nil, fmt.Errorf("unable to record database stats: %w", err)
}

See options.go for the full list of options.

exaring/otelpgx

OpenTelemetry Tracing instrumentation for PostgreSQL

Go

228

79 commits

updated Oct 8, 2026

See the code

README

Go Reference

otelpgx

Provides OpenTelemetry instrumentation for the jackc/pgx library.

Requirements

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

Usage

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

if err := otelpgx.RecordStats(conn); err != nil {
    return nil, fmt.Errorf("unable to record database stats: %w", err)
}

See options.go for the full list of options.

Project health

Overall

4.6/10

Maintained

3/10

Code review

10/10
OpenSSF Scorecard

Latest release

v0.12.1 · Oct 6, 2026

Releases this year

6

Significant stargazers

Mikhail Mazurskiy

253 followers · starred Mar 2026

Yi-Jyun Pan

679 followers · starred Dec 2025

Dan Buch

407 followers · starred Jul 2025

Achille

260 followers · starred Dec 2025