pg_tracing

pg_tracing

pg_tracing : Distributed Tracing for PostgreSQL

Overview

ID Extension Package Version Category License Language
6010
pg_tracing
pg_tracing
0.1.3
STAT
MIT
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd-r
No
Yes
Yes
Yes
yes
no
Relationships
See Also
pg_profile
pg_show_plans
pg_stat_kcache
pg_stat_monitor
pg_qualstats
pg_store_plans
pg_track_settings
pg_wait_sampling

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
0.1.3
18
17
16
15
14
pg_tracing -
RPM
PIGSTY
0.1.3
18
17
16
15
14
pg_tracing_$v -
DEB
PIGSTY
0.1.3
18
17
16
15
14
postgresql-$v-pg-tracing -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el8.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el9.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el9.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el10.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
el10.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
d12.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
d12.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
d13.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
d13.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
u22.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
u22.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
u24.x86_64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
u24.aarch64
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
PIGSTY 0.1.3
Package Version OS ORG SIZE File URL
pg_tracing_18 0.1.3 el8.x86_64 pigsty 46.2 KiB pg_tracing_18-0.1.3-2PIGSTY.el8.x86_64.rpm
pg_tracing_18 0.1.3 el8.aarch64 pigsty 44.8 KiB pg_tracing_18-0.1.3-2PIGSTY.el8.aarch64.rpm
pg_tracing_18 0.1.3 el9.x86_64 pigsty 43.9 KiB pg_tracing_18-0.1.3-2PIGSTY.el9.x86_64.rpm
pg_tracing_18 0.1.3 el9.aarch64 pigsty 43.3 KiB pg_tracing_18-0.1.3-2PIGSTY.el9.aarch64.rpm
pg_tracing_18 0.1.3 el10.x86_64 pigsty 44.4 KiB pg_tracing_18-0.1.3-2PIGSTY.el10.x86_64.rpm
pg_tracing_18 0.1.3 el10.aarch64 pigsty 43.7 KiB pg_tracing_18-0.1.3-2PIGSTY.el10.aarch64.rpm
postgresql-18-pg-tracing 0.1.3 d12.x86_64 pigsty 105.3 KiB postgresql-18-pg-tracing_0.1.3-2PIGSTY~bookworm_amd64.deb
postgresql-18-pg-tracing 0.1.3 d12.aarch64 pigsty 102.9 KiB postgresql-18-pg-tracing_0.1.3-2PIGSTY~bookworm_arm64.deb
postgresql-18-pg-tracing 0.1.3 d13.x86_64 pigsty 105.4 KiB postgresql-18-pg-tracing_0.1.3-2PIGSTY~trixie_amd64.deb
postgresql-18-pg-tracing 0.1.3 d13.aarch64 pigsty 103.5 KiB postgresql-18-pg-tracing_0.1.3-2PIGSTY~trixie_arm64.deb
postgresql-18-pg-tracing 0.1.3 u22.x86_64 pigsty 114.7 KiB postgresql-18-pg-tracing_0.1.3-2PIGSTY~jammy_amd64.deb
postgresql-18-pg-tracing 0.1.3 u22.aarch64 pigsty 113.7 KiB postgresql-18-pg-tracing_0.1.3-2PIGSTY~jammy_arm64.deb
postgresql-18-pg-tracing 0.1.3 u24.x86_64 pigsty 110.1 KiB postgresql-18-pg-tracing_0.1.3-2PIGSTY~noble_amd64.deb
postgresql-18-pg-tracing 0.1.3 u24.aarch64 pigsty 109.2 KiB postgresql-18-pg-tracing_0.1.3-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_tracing_17 0.1.3 el8.x86_64 pigsty 46.2 KiB pg_tracing_17-0.1.3-2PIGSTY.el8.x86_64.rpm
pg_tracing_17 0.1.3 el8.aarch64 pigsty 44.9 KiB pg_tracing_17-0.1.3-2PIGSTY.el8.aarch64.rpm
pg_tracing_17 0.1.3 el9.x86_64 pigsty 43.9 KiB pg_tracing_17-0.1.3-2PIGSTY.el9.x86_64.rpm
pg_tracing_17 0.1.3 el9.aarch64 pigsty 43.4 KiB pg_tracing_17-0.1.3-2PIGSTY.el9.aarch64.rpm
pg_tracing_17 0.1.3 el10.x86_64 pigsty 44.4 KiB pg_tracing_17-0.1.3-2PIGSTY.el10.x86_64.rpm
pg_tracing_17 0.1.3 el10.aarch64 pigsty 43.6 KiB pg_tracing_17-0.1.3-2PIGSTY.el10.aarch64.rpm
postgresql-17-pg-tracing 0.1.3 d12.x86_64 pigsty 105.4 KiB postgresql-17-pg-tracing_0.1.3-2PIGSTY~bookworm_amd64.deb
postgresql-17-pg-tracing 0.1.3 d12.aarch64 pigsty 103.0 KiB postgresql-17-pg-tracing_0.1.3-2PIGSTY~bookworm_arm64.deb
postgresql-17-pg-tracing 0.1.3 d13.x86_64 pigsty 105.6 KiB postgresql-17-pg-tracing_0.1.3-2PIGSTY~trixie_amd64.deb
postgresql-17-pg-tracing 0.1.3 d13.aarch64 pigsty 103.7 KiB postgresql-17-pg-tracing_0.1.3-2PIGSTY~trixie_arm64.deb
postgresql-17-pg-tracing 0.1.3 u22.x86_64 pigsty 129.3 KiB postgresql-17-pg-tracing_0.1.3-2PIGSTY~jammy_amd64.deb
postgresql-17-pg-tracing 0.1.3 u22.aarch64 pigsty 128.1 KiB postgresql-17-pg-tracing_0.1.3-2PIGSTY~jammy_arm64.deb
postgresql-17-pg-tracing 0.1.3 u24.x86_64 pigsty 110.2 KiB postgresql-17-pg-tracing_0.1.3-2PIGSTY~noble_amd64.deb
postgresql-17-pg-tracing 0.1.3 u24.aarch64 pigsty 109.2 KiB postgresql-17-pg-tracing_0.1.3-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_tracing_16 0.1.3 el8.x86_64 pigsty 46.2 KiB pg_tracing_16-0.1.3-2PIGSTY.el8.x86_64.rpm
pg_tracing_16 0.1.3 el8.aarch64 pigsty 44.9 KiB pg_tracing_16-0.1.3-2PIGSTY.el8.aarch64.rpm
pg_tracing_16 0.1.3 el9.x86_64 pigsty 43.9 KiB pg_tracing_16-0.1.3-2PIGSTY.el9.x86_64.rpm
pg_tracing_16 0.1.3 el9.aarch64 pigsty 43.3 KiB pg_tracing_16-0.1.3-2PIGSTY.el9.aarch64.rpm
pg_tracing_16 0.1.3 el10.x86_64 pigsty 44.5 KiB pg_tracing_16-0.1.3-2PIGSTY.el10.x86_64.rpm
pg_tracing_16 0.1.3 el10.aarch64 pigsty 43.5 KiB pg_tracing_16-0.1.3-2PIGSTY.el10.aarch64.rpm
postgresql-16-pg-tracing 0.1.3 d12.x86_64 pigsty 105.4 KiB postgresql-16-pg-tracing_0.1.3-2PIGSTY~bookworm_amd64.deb
postgresql-16-pg-tracing 0.1.3 d12.aarch64 pigsty 102.9 KiB postgresql-16-pg-tracing_0.1.3-2PIGSTY~bookworm_arm64.deb
postgresql-16-pg-tracing 0.1.3 d13.x86_64 pigsty 105.5 KiB postgresql-16-pg-tracing_0.1.3-2PIGSTY~trixie_amd64.deb
postgresql-16-pg-tracing 0.1.3 d13.aarch64 pigsty 103.5 KiB postgresql-16-pg-tracing_0.1.3-2PIGSTY~trixie_arm64.deb
postgresql-16-pg-tracing 0.1.3 u22.x86_64 pigsty 128.8 KiB postgresql-16-pg-tracing_0.1.3-2PIGSTY~jammy_amd64.deb
postgresql-16-pg-tracing 0.1.3 u22.aarch64 pigsty 127.6 KiB postgresql-16-pg-tracing_0.1.3-2PIGSTY~jammy_arm64.deb
postgresql-16-pg-tracing 0.1.3 u24.x86_64 pigsty 110.1 KiB postgresql-16-pg-tracing_0.1.3-2PIGSTY~noble_amd64.deb
postgresql-16-pg-tracing 0.1.3 u24.aarch64 pigsty 109.1 KiB postgresql-16-pg-tracing_0.1.3-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_tracing_15 0.1.3 el8.x86_64 pigsty 47.9 KiB pg_tracing_15-0.1.3-2PIGSTY.el8.x86_64.rpm
pg_tracing_15 0.1.3 el8.aarch64 pigsty 46.5 KiB pg_tracing_15-0.1.3-2PIGSTY.el8.aarch64.rpm
pg_tracing_15 0.1.3 el9.x86_64 pigsty 46.4 KiB pg_tracing_15-0.1.3-2PIGSTY.el9.x86_64.rpm
pg_tracing_15 0.1.3 el9.aarch64 pigsty 45.8 KiB pg_tracing_15-0.1.3-2PIGSTY.el9.aarch64.rpm
pg_tracing_15 0.1.3 el10.x86_64 pigsty 46.8 KiB pg_tracing_15-0.1.3-2PIGSTY.el10.x86_64.rpm
pg_tracing_15 0.1.3 el10.aarch64 pigsty 46.2 KiB pg_tracing_15-0.1.3-2PIGSTY.el10.aarch64.rpm
postgresql-15-pg-tracing 0.1.3 d12.x86_64 pigsty 108.2 KiB postgresql-15-pg-tracing_0.1.3-2PIGSTY~bookworm_amd64.deb
postgresql-15-pg-tracing 0.1.3 d12.aarch64 pigsty 105.3 KiB postgresql-15-pg-tracing_0.1.3-2PIGSTY~bookworm_arm64.deb
postgresql-15-pg-tracing 0.1.3 d13.x86_64 pigsty 108.2 KiB postgresql-15-pg-tracing_0.1.3-2PIGSTY~trixie_amd64.deb
postgresql-15-pg-tracing 0.1.3 d13.aarch64 pigsty 106.0 KiB postgresql-15-pg-tracing_0.1.3-2PIGSTY~trixie_arm64.deb
postgresql-15-pg-tracing 0.1.3 u22.x86_64 pigsty 132.0 KiB postgresql-15-pg-tracing_0.1.3-2PIGSTY~jammy_amd64.deb
postgresql-15-pg-tracing 0.1.3 u22.aarch64 pigsty 130.8 KiB postgresql-15-pg-tracing_0.1.3-2PIGSTY~jammy_arm64.deb
postgresql-15-pg-tracing 0.1.3 u24.x86_64 pigsty 113.1 KiB postgresql-15-pg-tracing_0.1.3-2PIGSTY~noble_amd64.deb
postgresql-15-pg-tracing 0.1.3 u24.aarch64 pigsty 112.4 KiB postgresql-15-pg-tracing_0.1.3-2PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_tracing_14 0.1.3 el8.x86_64 pigsty 48.2 KiB pg_tracing_14-0.1.3-2PIGSTY.el8.x86_64.rpm
pg_tracing_14 0.1.3 el8.aarch64 pigsty 47.3 KiB pg_tracing_14-0.1.3-2PIGSTY.el8.aarch64.rpm
pg_tracing_14 0.1.3 el9.x86_64 pigsty 46.6 KiB pg_tracing_14-0.1.3-2PIGSTY.el9.x86_64.rpm
pg_tracing_14 0.1.3 el9.aarch64 pigsty 46.3 KiB pg_tracing_14-0.1.3-2PIGSTY.el9.aarch64.rpm
pg_tracing_14 0.1.3 el10.x86_64 pigsty 47.3 KiB pg_tracing_14-0.1.3-2PIGSTY.el10.x86_64.rpm
pg_tracing_14 0.1.3 el10.aarch64 pigsty 46.8 KiB pg_tracing_14-0.1.3-2PIGSTY.el10.aarch64.rpm
postgresql-14-pg-tracing 0.1.3 d12.x86_64 pigsty 109.6 KiB postgresql-14-pg-tracing_0.1.3-2PIGSTY~bookworm_amd64.deb
postgresql-14-pg-tracing 0.1.3 d12.aarch64 pigsty 107.0 KiB postgresql-14-pg-tracing_0.1.3-2PIGSTY~bookworm_arm64.deb
postgresql-14-pg-tracing 0.1.3 d13.x86_64 pigsty 109.6 KiB postgresql-14-pg-tracing_0.1.3-2PIGSTY~trixie_amd64.deb
postgresql-14-pg-tracing 0.1.3 d13.aarch64 pigsty 107.5 KiB postgresql-14-pg-tracing_0.1.3-2PIGSTY~trixie_arm64.deb
postgresql-14-pg-tracing 0.1.3 u22.x86_64 pigsty 133.2 KiB postgresql-14-pg-tracing_0.1.3-2PIGSTY~jammy_amd64.deb
postgresql-14-pg-tracing 0.1.3 u22.aarch64 pigsty 132.7 KiB postgresql-14-pg-tracing_0.1.3-2PIGSTY~jammy_arm64.deb
postgresql-14-pg-tracing 0.1.3 u24.x86_64 pigsty 114.1 KiB postgresql-14-pg-tracing_0.1.3-2PIGSTY~noble_amd64.deb
postgresql-14-pg-tracing 0.1.3 u24.aarch64 pigsty 113.9 KiB postgresql-14-pg-tracing_0.1.3-2PIGSTY~noble_arm64.deb

Source

pig build pkg pg_tracing;# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u # add both repo and update cache

Install this extension with pig:

pig install pg_tracing;# install via package name, for the active PG version  pig install pg_tracing -v 18; # install for PG 18 pig install pg_tracing -v 17; # install for PG 17 pig install pg_tracing -v 16; # install for PG 16 pig install pg_tracing -v 15; # install for PG 15 pig install pg_tracing -v 14; # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_tracing';

Create this extension with:

CREATE EXTENSION pg_tracing;

Usage

pg_tracing: distributed tracing for PostgreSQL

pg_tracing generates server-side spans for distributed tracing. It creates spans for planner, executor, plan nodes, nested queries, triggers, parallel workers, and transaction commits.

Trace Propagation via SQLCommenter

Pass trace context as a SQL comment. Queries with a sampled flag will generate spans:

/*traceparent='00-00000000000000000000000000000123-0000000000000123-01'*/ SELECT 1;

Trace Propagation via GUC

BEGIN; SET LOCAL pg_tracing.trace_context='traceparent=''00-00000000000000000000000000000005-0000000000000005-01'''; UPDATE pgbench_accounts SET abalance=1 WHERE aid=1; COMMIT;

Standalone Sampling

Randomly sample queries without external trace context:

SET pg_tracing.sample_rate = 1.0; -- trace all queries SELECT 1;

Viewing Spans

-- Consume spans (removes them from buffer) SELECT trace_id, parent_id, span_id, span_start, span_end, span_type, span_operation FROM pg_tracing_consume_spans ORDER BY span_start;  -- Peek at spans (non-destructive) SELECT * FROM pg_tracing_peek_spans;  -- Export as OTLP JSON SELECT pg_tracing_json_spans();

Statistics

SELECT * FROM pg_tracing_info; SELECT pg_tracing_reset();

Sending Spans to OpenTelemetry Collector

Configure in postgresql.conf:

pg_tracing.otel_endpoint = http://127.0.0.1:4318/v1/traces pg_tracing.otel_naptime = 2000

Key GUC Parameters

Parameter Default Description
pg_tracing.max_span 10000 Maximum spans in shared memory
pg_tracing.track all Which statements to track
pg_tracing.sample_rate 0 Fraction of queries to sample randomly
pg_tracing.otel_endpoint (empty) OTLP HTTP endpoint for span export
Last updated on