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 sqlcommenting support to MySQL driver instrumentors #2902

Open
3 of 4 tasks
tammy-baylis-swi opened this issue Oct 11, 2024 · 1 comment · Fixed by #2897
Open
3 of 4 tasks

Add sqlcommenting support to MySQL driver instrumentors #2902

tammy-baylis-swi opened this issue Oct 11, 2024 · 1 comment · Fixed by #2897
Assignees

Comments

@tammy-baylis-swi
Copy link
Contributor

tammy-baylis-swi commented Oct 11, 2024

What problem do you want to solve?

The community instrumentors for psycopg2 and psycopg provide sqlcommenting at the database "driver" level so that context is added to PostgreSQL query statements for the actual requests to database servers to select/insert/etc.

Example:
2024-10-11 19:54:22 UTC,4/1731,0,LOG,00000,"statement: SELECT * FROM city WHERE id = '1819' /*db_driver='psycopg2%3A2.9.9',dbapi_level='2.0',dbapi_threadsafety=2,driver_paramstyle='pyformat',libpq_version=150008,traceparent='00-<TRACE_ID>-<SPAN_ID>-01'*/",,,,,,,,,"","client backend",,0

For MySQL, sqlcommenting must be done at a higher level of abstraction through instrumentation of the ORM sqlalchemy while using a MySQL database driver, which can also be instrumented (mysql-connector, mysqlclient, pymysql). The result is different from driver-level sqlcommenting because the <SPAN_ID> in the traceparent KV of the comment is for the span from sqlalchemy, not the span ID of the database driver.

It would be great to have consistent sqlcommenting whether using MySQL or PostgreSQL.

Describe the solution you'd like

I'd like to implement sqlcommenting support for the existing mysql-connector, mysqlclient, pymysql instrumentors.

Describe alternatives you've considered

No response

Additional Context

This does overlap with open issue #1387

This may close #2826

Would you like to implement a fix?

Yes

@tammy-baylis-swi
Copy link
Contributor Author

This does overlap with open issue #1387

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment