Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

overmindtech/otelpgx

Repository files navigation

Go Reference

otelpgx

Provides OpenTelemetry instrumentation for the jackc/pgx library.

Requirements

  • go 1.22 (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/overmindtech/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.

About

OpenTelemetry Tracing instrumentation for PostgreSQL

Resources

License

Stars

Watchers

Forks

Packages

Contributors

Languages

  • Go 99.5%
  • Makefile 0.5%

AltStyle によって変換されたページ (->オリジナル) /