dd-trace-java
dd-trace-java copied to clipboard
Add backend PID tag to spans for Postgres operations
The Postgres implementation of java.sql.Connection, org.postgresql.jdbc.PgConnection, exposes a getBackendPID method which returns the process ID within the database which supports the current connection. This serves, in effect, as a unique identifier for the connection/session.
The idle_in_transaction_session_timeout setting of the PostgreSQL server can result in a situation where a single connection used by multiple independent tasks is terminated because one task idles for too long. Debugging situations like this would be easier if traces exposed the backend PID, making it possible to determine which operations share the same connection.