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

Support psycopg 3 #2427

Open
antoine-de opened this issue Oct 10, 2023 · 9 comments
Open

Support psycopg 3 #2427

antoine-de opened this issue Oct 10, 2023 · 9 comments
Labels
Enhancement New feature or request New Integration Integrating with a new framework or library Triaged Has been looked at recently during old issue triage

Comments

@antoine-de
Copy link

Problem Statement

Hi, I'm not sure if I'm missing something but I cannot find sentry's support for psycopg v3 (well, named psycopg ) and If I try a simple test I cannot find sql query information in sentry when using psycopg3.

Am I missing something ? I feel like I'm missing something since I cannot also find the psycopg2 integration, but I'm not very familiar with sentry's code, so maybe I'm looking in the wrong places.

And if it's not yet supported, do you plan to support it?

Thanks for this great project!

Solution Brainstorm

I guess, we would have to add a specific integration for psycopg3. I'm not sure I feel confident to do a correct and clean implementation of this, but I can try if you want.

@antoine-de antoine-de added the Enhancement New feature or request label Oct 10, 2023
@antoine-de
Copy link
Author

Note: For the solution, I'm not aware of all the implication, but maybe we can also just implement this as an opentelemetry-python-contrib integration (they have psycopg2 but not psycopg3 yet (cf open-telemetry/opentelemetry-python-contrib#1751).

But I did not manage to make the sentry OTEL integration work and send performance report to sentry 😅

@sentrivana sentrivana added New Integration Integrating with a new framework or library and removed Waiting for: Product Owner labels Oct 11, 2023
@antonpirker
Copy link
Member

Hey @antoine-de!

Thanks for writing in! We have no integrations for the low level psycopg lib but for higher level database access libs like Django ORM or SQLAlchemy or asyncpg.

In my test application I have psycopg==3.1.12 and the spans show up as expected.

How do you connect to your database?

@antoine-de
Copy link
Author

I only use psycopg directly, no ORM, so I do things like:

with psycopg.connect("url") as conn:
    conn.execute("some sql") # or use a cursor

@sentrivana
Copy link
Contributor

In that case it's expected behavior that nothing shows up in Sentry @antoine-de -- we'd need an integration specifically for psycopg, which doesn't exist at the moment.

We don't have any concrete plans to add it in the near future. However, if you or someone else feels like contributing it, please go ahead! We have this checklist that might be helpful and one can also get inspired by the existing DB integrations (e.g. asyncpg). It also doesn't have to be perfect, we can iron out the details during PR review.

@vagi8
Copy link
Contributor

vagi8 commented Oct 27, 2023

Hey @sentrivana,

I wanted to work on creating this integration. As psycopg2 (v2) and psycopg (v3) are different packages, my first idea is I can just develop it for v2 because v2 has got lot more user community than v3.

Should this new integration be for version V2.9.9 which is the latest version ?

Also should this be the place to ask any questions I might have in regards to this ?

@antonpirker
Copy link
Member

As described in my comment above (#2427 (comment)) we do not need a dedicated psycopg3 integrations, because we hook into sqlalchemy and django.

So please do not create an integration @vagi8 !
But thanks for the dedication! Really love it.

(and also thanks for patience with the django pr you supplied)

@antoine-de
Copy link
Author

I'm not sure I understand @antonpirker , don't sentry also need a psycopg3 integration for users using psycopg3 without sqlalchemy or django?

For my use case, I added a simple spycopg3 integration directly in my project to iterate quickly (here), but I can try to send a PR if you think this can be useful to others.

@antonpirker
Copy link
Member

Yes for the case that you do not use SQLAlchemy or Django a distinct integration would be useful. I just meant if you use SQLAlchemy or Django, then psycopg3 should "just work".

In this case a distinct integration would definitely make sense. (I honestly was not thinking about people using a postgres db without ORM)

@antoine-de
Copy link
Author

No problem, I might be a weird one for not liking ORMs too much 😁

I'll try to find the time to open a PR with what I have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request New Integration Integrating with a new framework or library Triaged Has been looked at recently during old issue triage
Projects
Status: No status
Development

No branches or pull requests

4 participants