Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to retrieve connection id from connection/transaction (CommonQueryMethods)? #647

Open
joe-squint opened this issue Sep 20, 2024 · 0 comments
Labels

Comments

@joe-squint
Copy link

joe-squint commented Sep 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants