Tech News
← Back to articles

pg_tracing: Distributed Tracing for PostgreSQL

read original related products more articles

pg_tracing is a PostgreSQL extension that generates server-side spans for distributed tracing.

When pg_tracing is active, it generates spans on sampled queries. To access these spans, the extension provides two ways:

pg_tracing_consume_spans and pg_tracing_peek_spans views output spans as a set of records

and views output spans as a set of records pg_tracing_json_spans function outputs spans as a OTLP json

The utility functions pg_tracing_reset and pg_tracing_info provide ways to read and reset extension's statistics. These are not available globally but can be enabled for a specific database with CREATE EXTENSION pg_tracing .

There are currently two mechanisms to propagate trace context:

As a SQL comment using SQLCommenter

As a GUC parameter pg_tracing.trace_context

See Trace Propagation for more details.

Warning This extension is still in early development and may be unstable.

... continue reading