You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 thetraceparent
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
The text was updated successfully, but these errors were encountered: