Documentation ¶
Index ¶
- func WithNextTracer(nextTracer Tracer) queryMeterOption
- func WithQueryMeter(mp metric.MeterProvider) queryMeterOption
- type QueryMeter
- func (q *QueryMeter) TraceBatchEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchEndData)
- func (q *QueryMeter) TraceBatchQuery(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchQueryData)
- func (q *QueryMeter) TraceBatchStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchStartData) context.Context
- func (q *QueryMeter) TraceConnectEnd(ctx context.Context, data pgx.TraceConnectEndData)
- func (q *QueryMeter) TraceConnectStart(ctx context.Context, data pgx.TraceConnectStartData) context.Context
- func (q *QueryMeter) TracePrepareEnd(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareEndData)
- func (q *QueryMeter) TracePrepareStart(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareStartData) context.Context
- func (q *QueryMeter) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryEndData)
- func (q *QueryMeter) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryStartData) context.Context
- type QueryTracer
- func (t *QueryTracer) TraceBatchEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchEndData)
- func (t *QueryTracer) TraceBatchQuery(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchQueryData)
- func (t *QueryTracer) TraceBatchStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchStartData) context.Context
- func (t *QueryTracer) TraceConnectEnd(ctx context.Context, data pgx.TraceConnectEndData)
- func (t *QueryTracer) TraceConnectStart(ctx context.Context, data pgx.TraceConnectStartData) context.Context
- func (t *QueryTracer) TraceCopyFromEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceCopyFromEndData)
- func (t *QueryTracer) TraceCopyFromStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceCopyFromStartData) context.Context
- func (t *QueryTracer) TracePrepareEnd(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareEndData)
- func (t *QueryTracer) TracePrepareStart(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareStartData) context.Context
- func (t *QueryTracer) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryEndData)
- func (t *QueryTracer) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryStartData) context.Context
- type Tracer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithNextTracer ¶
func WithNextTracer(nextTracer Tracer) queryMeterOption
func WithQueryMeter ¶
func WithQueryMeter(mp metric.MeterProvider) queryMeterOption
Types ¶
type QueryMeter ¶
type QueryMeter struct {
// contains filtered or unexported fields
}
func NewQueryMeter ¶
func NewQueryMeter(options ...queryMeterOption) (*QueryMeter, error)
func (*QueryMeter) TraceBatchEnd ¶
func (q *QueryMeter) TraceBatchEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchEndData)
func (*QueryMeter) TraceBatchQuery ¶
func (q *QueryMeter) TraceBatchQuery(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchQueryData)
func (*QueryMeter) TraceBatchStart ¶
func (q *QueryMeter) TraceBatchStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchStartData) context.Context
func (*QueryMeter) TraceConnectEnd ¶
func (q *QueryMeter) TraceConnectEnd(ctx context.Context, data pgx.TraceConnectEndData)
func (*QueryMeter) TraceConnectStart ¶
func (q *QueryMeter) TraceConnectStart(ctx context.Context, data pgx.TraceConnectStartData) context.Context
func (*QueryMeter) TracePrepareEnd ¶
func (q *QueryMeter) TracePrepareEnd(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareEndData)
func (*QueryMeter) TracePrepareStart ¶
func (q *QueryMeter) TracePrepareStart(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareStartData) context.Context
func (*QueryMeter) TraceQueryEnd ¶
func (q *QueryMeter) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryEndData)
func (*QueryMeter) TraceQueryStart ¶
func (q *QueryMeter) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryStartData) context.Context
type QueryTracer ¶
type QueryTracer struct { // Name of the tracer Name string // Options to provide to the tracer Options []trace.TracerOption }
QueryTracer is a wrapper around the pgx tracer interfaces which instrument queries.
Example ¶
config, err := pgxpool.ParseConfig(os.Getenv("PGX_DATABASE_URL")) if err != nil { panic(err) } config.ConnConfig.Tracer = &pgxotel.QueryTracer{ Name: "example-api", } conn, err := pgxpool.NewWithConfig(context.TODO(), config) if err != nil { panic(err) } // close the connection defer conn.Close() rows, err := conn.Query(context.TODO(), "SELECT * from customer") if err != nil { panic(err) } // close the rows defer rows.Close() // Customer struct must be defined type Customer struct { FirstName string `db:"first_name"` LastName string `db:"last_name"` } for rows.Next() { customer, err := pgx.RowToStructByName[Customer](rows) if err != nil { panic(err) } fmt.Println(customer.FirstName) }
Output:
func (*QueryTracer) TraceBatchEnd ¶
func (t *QueryTracer) TraceBatchEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchEndData)
TraceBatchEnd implements pgx.BatchTracer.
func (*QueryTracer) TraceBatchQuery ¶
func (t *QueryTracer) TraceBatchQuery(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchQueryData)
TraceBatchQuery implements pgx.BatchTracer.
func (*QueryTracer) TraceBatchStart ¶
func (t *QueryTracer) TraceBatchStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchStartData) context.Context
TraceBatchStart implements pgx.BatchTracer.
func (*QueryTracer) TraceConnectEnd ¶
func (t *QueryTracer) TraceConnectEnd(ctx context.Context, data pgx.TraceConnectEndData)
TraceConnectEnd implements pgx.ConnectTracer.
func (*QueryTracer) TraceConnectStart ¶
func (t *QueryTracer) TraceConnectStart(ctx context.Context, data pgx.TraceConnectStartData) context.Context
TraceConnectStart implements pgx.ConnectTracer.
func (*QueryTracer) TraceCopyFromEnd ¶
func (t *QueryTracer) TraceCopyFromEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceCopyFromEndData)
TraceCopyFromEnd implements pgx.CopyFromTracer.
func (*QueryTracer) TraceCopyFromStart ¶
func (t *QueryTracer) TraceCopyFromStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceCopyFromStartData) context.Context
TraceCopyFromStart implements pgx.CopyFromTracer.
func (*QueryTracer) TracePrepareEnd ¶
func (t *QueryTracer) TracePrepareEnd(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareEndData)
TracePrepareEnd implements pgx.PrepareTracer.
func (*QueryTracer) TracePrepareStart ¶
func (t *QueryTracer) TracePrepareStart(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareStartData) context.Context
TracePrepareStart implements pgx.PrepareTracer.
func (*QueryTracer) TraceQueryEnd ¶
func (t *QueryTracer) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryEndData)
TraceQueryEnd implements pgx.QueryTracer.
func (*QueryTracer) TraceQueryStart ¶
func (t *QueryTracer) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryStartData) context.Context
TraceQueryStart implements pgx.QueryTracer.
Click to show internal directories.
Click to hide internal directories.