Description
In our project, we have the roarr logs of Slonik enabled alongside our own application logs. We'd like to correlate the roarr logs with our existing application logs by adding the connection id into our application log context, while leaving the roarr logs as is. I can see the connection id is present in the interceptor context, but I'm wondering if I there's a way I could retrieve this connection id from the connection itself?
Desired Behavior
After calling pool.connect
the resulting connection object contains a connection id that can be accessed to correlate roarr logs with other logs and data.
Motivation
Today we have access to the roarr logs, but using them effectively can be difficult since we cannot easily correlate them with the rest of the contextual data that our services log. If our service is processing two identical requests at the same time, it can become impossible to attribute the roar logs to the individual request context within our application logs.
Implementation
A simple solution for this could be to add a getConnectionId
or getContext
method into CommonQueryMethods
to allow connections and transactions the ability to expose the connection id