Skip to content

Tracing and errors monitoring

go-pg supports tracing out-of-the-box using OpenTelemetry API. To enable queries instrumentation, use the following code:

import (

db := pg.Connect(&pg.Options{...})


The hook sends SELECT, UPDATE, and DELETE queries as is. But it strips data values from INSERT queries since they can contain sensitive information.

This is how span looks at which is an OpenTelemetry backend that supports distributed traces, logs, and errors.

PostgreSQL trace and spans