Provides OpenTelemetry instrumentation for the jackc/pgx library.
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.
Overall
Maintained
Code review
Go module
Latest release
Releases this year
253 followers · starred Mar 2026
679 followers · starred Dec 2025
407 followers · starred Jul 2025
260 followers · starred Dec 2025
Provides OpenTelemetry instrumentation for the jackc/pgx library.
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.
Overall
Maintained
Code review
Go module
Latest release
Releases this year
253 followers · starred Mar 2026
679 followers · starred Dec 2025
407 followers · starred Jul 2025
260 followers · starred Dec 2025