-
Notifications
You must be signed in to change notification settings - Fork 509
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
fix(django): improve getting psycopg3 connection info #3580
Conversation
This might need additional changes, but I'd like to know if this is a viable approach to address #3573. I didn't investigate how |
Thanks for the PR, @nijel! I just approved our test suit to run against it – let's see whether anything fails |
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #3580 +/- ##
==========================================
- Coverage 84.29% 84.27% -0.03%
==========================================
Files 133 133
Lines 14028 14031 +3
Branches 2956 2957 +1
==========================================
- Hits 11825 11824 -1
- Misses 1464 1466 +2
- Partials 739 741 +2
|
Hi @nijel, to be honest I am not super familiar with psycopg3 (someone else from the team wrote this part of the integration). Could you please explain why you are only including the |
These are the only fields used in the code below (+ Unix socket which I didn't figure out how to obtain). |
I've adjusted the code to expose all PostgreSQL connection parameters even when they are currently not used. I've also verified that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we go back to what you had in c862f55? This pgconn
stuff appears to be internal to psycopg3 because it is not super well documented from what I can tell, which makes me worried that this logic could break.
Your original suggestion is fine with me; the only reason I was originally worried about it is because I did not look at the code outside the diff where we actually use the connection_params
. As soon as you explained that we are only using some of the parameters, I realized I needed to expand that section, and now I see that you were correct that those are the only parameters we need.
Also, have you already tested this change? Did you notice a performance improvement?
The problem with the implementation in c862f55 is that when using UNIX sockets, it returns part of the UNIX socket path as This change makes profiling overhead not measurable compared to the original code as shown in #3573, so it does address the issue I experienced. |
Could you share an example of how c862f55 changes the Would it be possible for us to trim this UNIX socket path out of the |
The new code returns the same values (+ some additional settings which are not used). The The alternate approach to the current patch would be to use |
@nijel Just making sure I understand correctly:
Are all of those three points correct? If yes, then I think we should go with your suggestion, where we use c862f55 but only add the
|
Fetch the few needed parameters manually instead of relying on `get_parameters()` which adds visible overhead due to excluding default values for parameters.
Yes, all points are correct. I've adjusted the code accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Thanks for the contribution @nijel!
Fetch the few needed parameters manually instead of relying on
get_parameters()
which adds visible overhead due to excluding default values for parameters.Fixes #3573
Thank you for contributing to
sentry-python
! Please add tests to validate your changes, and lint your code usingtox -e linters
.Running the test suite on your PR might require maintainer approval. The AWS Lambda tests additionally require a maintainer to add a special label, and they will fail until this label is added.