Skip to content


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{...})


OpenTelemetryHook 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