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

[Feature Request] Override log.Logger in NewSession and ExecuteQuery #634

Open
zolstein opened this issue Feb 28, 2025 · 2 comments
Open

Comments

@zolstein
Copy link
Contributor

zolstein commented Feb 28, 2025

It would be useful to have the ability to override the log.Logger configured on the driver when calling ExecuteQuery or creating a new session. This way, callers could use a logger that includes context specific to the query / session, to help correlate (e.g.) query error logs with the originating query.

Motivating case: if a query experiences frequent deadlocks or other transient errors that don't bubble up to the application code, it can be difficult to identify which query causes the error logs.

sessionWithContext already includes a copy of the logger internally - I think all that's required is that a log.Logger is added as a field on SessionConfg / ExectueQueryConfiguration, and that this is allowed to override the logger from the driver when the session is created.

@zolstein
Copy link
Contributor Author

I opened a pull-request with a potential implementation here.

@StephenCathcart
Copy link
Contributor

StephenCathcart commented Mar 3, 2025

Hi @zolstein, thanks for taking the time to open this.

This seems like a reasonable suggestion, especially for cases like tracking transient errors more effectively. I'll bring it up with the team and see if we can add support for this.

Would you expect the session/query logger to fall back to the driver’s logger if unset, with the logger on the session-level being optional? I've seen your implementation and can see you've suggested adding an ExecuteQueryWithLogger which is a nice approach 👍.

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

No branches or pull requests

2 participants