Documentation
¶
Overview ¶
Package sql_tracing provides pgx v5 query tracing for distributed tracing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var QueryParametersKey = attribute.Key("pgx.query.parameters")
QueryParametersKey is the attribute key for storing query arguments.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Provider is the tracer provider used to create tracers.
Provider tracing.TracerProvider
// EnableStatement determines whether to include SQL statements in spans.
EnableStatement bool
// EnableArgs determines whether to include query arguments in spans.
EnableArgs bool
}
Config holds the configuration for SQL query tracing.
func (Config) QueryTracer ¶
func (c Config) QueryTracer() pgx.QueryTracer
QueryTracer returns a pgx QueryTracer for instrumenting database queries. It returns a no-op tracer if the provider is a no-op.
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer implements pgx.QueryTracer for tracing SQL queries.
func (Tracer) TraceQueryEnd ¶
TraceQueryEnd ends the span for a database query and records any errors. It skips recording errors for sql.ErrNoRows.
func (Tracer) TraceQueryStart ¶
func (t Tracer) TraceQueryStart(ctx context.Context, _ *pgx.Conn, data pgx.TraceQueryStartData) context.Context
TraceQueryStart creates a span for the beginning of a database query. It extracts the operation label from context or from the SQL statement (for BEGIN/COMMIT). The span includes the SQL statement and arguments if configured. Returns the context with the span attached.