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

add support for psycopg3 #396

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

add support for psycopg3 #396

wants to merge 5 commits into from

Conversation

Dilski
Copy link

@Dilski Dilski commented Jul 21, 2023

Issue #, if available: #395

Description of changes: Add support for psycopg3 (now just psycopg)

I have not been able to test this locally, as I can't find any development documentation in this repo.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Dilski Dilski requested a review from a team as a code owner July 21, 2023 13:46
@carolabadeer
Copy link
Contributor

carolabadeer commented Jul 31, 2023

Hi @Dilski, thanks for contributing this instrumentation!
Some workflow unit tests are failing, can you please take a look and address the issues? Also curious if you are still unable to test this instrumentation end-to-end locally? Hopefully these steps can help:

  • Set up a simple sample application that makes a psycopg3 request, imports & uses the new instrumentation in this PR
  • Set up the AWS X-Ray daemon locally
  • Run the sample app once you have the daemon running as a sidecar. The X-Ray console should reflect the instrumented psycopg3 call

Please let us know if you have any questions or need more help setting up a local end-to-end test. (Referencing #395)

@csteinle
Copy link

Hi @Dilski, thanks for contributing this instrumentation! Some workflow unit tests are failing, can you please take a look and address the issues? Also curious if you are still unable to test this instrumentation end-to-end locally? Hopefully these steps can help:

  • Set up a simple sample application that makes a psycopg3 request, imports & uses the new instrumentation in this PR
  • Set up the AWS X-Ray daemon locally
  • Run the sample app once you have the daemon running as a sidecar. The X-Ray console should reflect the instrumented psycopg3 call

Please let us know if you have any questions or need more help setting up a local end-to-end test. (Referencing #395)

Hi @carolabadeer - we've tried to address the issues and have managed to run the test suite at our side. Can we request a re-review?

Copy link
Contributor

@carolabadeer carolabadeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small comments, but otherwise looking good!

Thanks @Dilski and @csteinle for addressing the CI issues and testing the instrumentation locally. I think it would also be very helpful to add a new section to the ReadMe for this instrumentation. It can contain a short code snippet (similar to these sections) on how to setup and use the psycopg3 instrumentation

_xray_register_default_jsonb_fix
'psycopg_pool.pool',
'ConnectionPool._connect',
_xray_traced_connect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give some insight into why these specific functions are being wrapped? I see a new dependency on psycopg pool that was not there in the initial commit, what is this package responsible for and is it sufficient to only patch the connection?

)


def _xray_traced_connect(wrapped, instance, args, kwargs):
conn = wrapped(*args, **kwargs)
parameterized_dsn = {c[0]: c[-1] for c in map(methodcaller('split', '='), conn.dsn.split(' '))}
parameterized_dsn = {c[0]: c[-1] for c in map(methodcaller('split', '='), conn.info.dsn.split(' '))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: add a comment explaining what parameterized_dsn is for readability

@jhubberts
Copy link

Hey folks, any progress on this? I'd also like to take advantage of this patching logic once it's in, and am weighing whether it's worth waiting for a contribution back to aws_xray_sdk, or just patching it in my own package.

@Dilski
Copy link
Author

Dilski commented Oct 9, 2023

@jhubberts this is something we want in, but haven't prioritised/had the time to address feedback on. Any help would be appreciated

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

Successfully merging this pull request may close these issues.

4 participants