pgxtracer

package
v0.0.0-...-425f0b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pgxtracer provides a tracer implementation for pgx.

databaseConfig, err := pgxpool.ParseConfig(fmt.Sprintf(
	"user=%s password=%s host=%s port=%d dbname=%s sslmode=disable pool_max_conn_lifetime=15m pool_max_conn_idle_time=30m pool_health_check_period=1m",
	configuration.Database.User,
	configuration.Database.Password,
	configuration.Database.Hostname,
	configuration.Database.Port,
	configuration.Database.Database))
if err != nil {
	return fmt.Errorf("parsing database configuration: %w", err)
}

databaseConf := databaseConfig.Copy()

databaseConf.ConnConfig.Tracer = pgxtracer.NewSentryPgxTracer()

database, err := pgxpool.NewWithConfig(c.Context, databaseConf)
if err != nil {
	return fmt.Errorf("connecting to database: %w", err)
}
defer database.Close()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSentryPgxTracer

func NewSentryPgxTracer(opts ...SentryPgxTracerOption) pgx.QueryTracer

Types

type SentryPgxTracerOption

type SentryPgxTracerOption func(*Tracer)

func WithDatabaseName

func WithDatabaseName(databaseName string) SentryPgxTracerOption

func WithServerAddress

func WithServerAddress(hostname string, port string) SentryPgxTracerOption

func WithTag

func WithTag(key, value string) SentryPgxTracerOption

func WithTags

func WithTags(tags map[string]string) SentryPgxTracerOption

type Tracer

type Tracer struct {
	// contains filtered or unexported fields
}

func (Tracer) TraceQueryEnd

func (t Tracer) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryEndData)

func (Tracer) TraceQueryStart

func (t Tracer) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryStartData) context.Context

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL