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 DB-API integration optional connect_module to instrument_connection #3028

Closed
tammy-baylis-swi opened this issue Nov 20, 2024 · 0 comments · Fixed by #3027
Closed

Add DB-API integration optional connect_module to instrument_connection #3028

tammy-baylis-swi opened this issue Nov 20, 2024 · 0 comments · Fixed by #3027

Comments

@tammy-baylis-swi
Copy link
Contributor

tammy-baylis-swi commented Nov 20, 2024

What problem do you want to solve?

Generally there are two ways to instrument a Python client-side database driver client framework: instrument() or instrument_connection(). The former seems to be the most-advertised in the docs (e.g. psycopg2, mysqlclient docs) and is also how some distros set up instrumentation (e.g. load_instrumentor). Users can still call instrument_connection() in-code and I'd like to improve this method.

DB-API integration's wrap_connect is used by multiple instrumentors. It accepts connect_module to optionally use for wrapping/unwrapping and populating sqlcomment when opted in.

DB-API integration's instrumentation_connection is called by the instrumentors for mysql-connector, mysqlclient, PyMySQL, and sqlite3. (psycopg2 does it own thing.) Currently this does not accept connect_module. This is needed to better support sqlcommenting by those MySQL driver instrumentors (see also #2902). Otherwise, sqlcomment will populate with db_driver='unknown%%3Aunknown' -- it doesn't currently because not yet implemented on main.

Describe the solution you'd like

Get DB-API instrument_connection to accept optional connect_module

Describe alternatives you've considered

No response

Additional Context

Relates to #2902

Would you like to implement a fix?

Yes

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