Documentation ¶
Index ¶
- Variables
- type ContextKey
- type PoolCollector
- type QueryCollector
- func (q *QueryCollector) Collect(metrics chan<- prometheus.Metric)
- func (q *QueryCollector) Describe(descs chan<- *prometheus.Desc)
- func (q *QueryCollector) TraceBatchEnd(ctx context.Context, conn *pgx.Conn, args pgx.TraceBatchEndData)
- func (q *QueryCollector) TraceBatchQuery(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchQueryData)
- func (q *QueryCollector) TraceBatchStart(ctx context.Context, conn *pgx.Conn, args pgx.TraceBatchStartData) context.Context
- func (q *QueryCollector) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, args pgx.TraceQueryEndData)
- func (q *QueryCollector) TraceQueryStart(ctx context.Context, conn *pgx.Conn, args pgx.TraceQueryStartData) context.Context
- type TraceBatchData
- type TraceQueryData
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var TraceBatchKey = &ContextKey{ name: reflect.TypeOf(TraceBatchData{}).PkgPath(), }
TraceBatchKey represents the context key of the data.
var TraceQueryKey = &ContextKey{ name: reflect.TypeOf(TraceQueryData{}).PkgPath(), }
TraceQueryKey represents the context key of the data.
Functions ¶
This section is empty.
Types ¶
type ContextKey ¶
type ContextKey struct {
// contains filtered or unexported fields
}
ContextKey represents a context key.
func (*ContextKey) String ¶
func (k *ContextKey) String() string
String returns the context key as a string.
type PoolCollector ¶
type PoolCollector struct {
// contains filtered or unexported fields
}
PoolCollector is a Prometheus pool collector for pgx metrics.
Example ¶
package main import ( "context" "os" "github.com/jackc/pgx/v5/pgxpool" "github.com/pgx-contrib/pgxprom" "github.com/prometheus/client_golang/prometheus" ) func main() { config, err := pgxpool.ParseConfig(os.Getenv("PGX_DATABASE_URL")) if err != nil { panic(err) } pool, err := pgxpool.NewWithConfig(context.TODO(), config) if err != nil { panic(err) } collector := pgxprom.NewPoolCollector() // register the pool collector.Add(pool) // register the collector if err := prometheus.Register(collector); err != nil { panic(err) } }
Output:
func NewPoolCollector ¶
func NewPoolCollector() *PoolCollector
NewPoolCollector returns a new collector.
func (*PoolCollector) Add ¶
func (p *PoolCollector) Add(pool *pgxpool.Pool)
Add append the pool the collector
func (*PoolCollector) Collect ¶
func (p *PoolCollector) Collect(metrics chan<- prometheus.Metric)
Collect implements the prometheus.Collector interface.
func (*PoolCollector) Describe ¶
func (p *PoolCollector) Describe(descs chan<- *prometheus.Desc)
Describe implements the prometheus.Collector interface.
func (*PoolCollector) Remove ¶
func (p *PoolCollector) Remove(pool *pgxpool.Pool)
Remove removes the pool from the collector
type QueryCollector ¶
type QueryCollector struct {
// contains filtered or unexported fields
}
QueryCollector is a Prometheus query collector for pgx metrics.
func NewQueryCollector ¶
func NewQueryCollector() *QueryCollector
NewQueryCollector creates a new Tracer.
func (*QueryCollector) Collect ¶
func (q *QueryCollector) Collect(metrics chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*QueryCollector) Describe ¶
func (q *QueryCollector) Describe(descs chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
func (*QueryCollector) TraceBatchEnd ¶
func (q *QueryCollector) TraceBatchEnd(ctx context.Context, conn *pgx.Conn, args pgx.TraceBatchEndData)
TraceBatchEnd implements pgx.BatchTracer.
func (*QueryCollector) TraceBatchQuery ¶
func (q *QueryCollector) TraceBatchQuery(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchQueryData)
TraceBatchQuery implements pgx.BatchTracer.
func (*QueryCollector) TraceBatchStart ¶
func (q *QueryCollector) TraceBatchStart(ctx context.Context, conn *pgx.Conn, args pgx.TraceBatchStartData) context.Context
TraceBatchStart implements pgx.BatchTracer.
func (*QueryCollector) TraceQueryEnd ¶
func (q *QueryCollector) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, args pgx.TraceQueryEndData)
TraceQueryEnd implements pgx.QueryTracer.
func (*QueryCollector) TraceQueryStart ¶
func (q *QueryCollector) TraceQueryStart(ctx context.Context, conn *pgx.Conn, args pgx.TraceQueryStartData) context.Context
TraceQueryStart implements pgx.QueryTracer.
type TraceBatchData ¶
TraceBatchData represents a batch data