Skip to content

Conversation

@tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Sep 2, 2025

Description

Stops stacktraces when programmatic instrumentation with sqlcommenting is enabled in some cases.

Fixes #3730

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review September 2, 2025 20:03
@tammy-baylis-swi tammy-baylis-swi requested a review from a team as a code owner September 2, 2025 20:03
@tammy-baylis-swi tammy-baylis-swi moved this to Ready for review in @xrmx's Python PR digest Sep 2, 2025
Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

Please add some docker tests, I fixed a crash in the psycopg commenter code extracting the libpq version recently and the mocks were not matching reality.

@xrmx xrmx moved this from Ready for review to Reviewed PRs that need fixes in @xrmx's Python PR digest Oct 10, 2025
@tammy-baylis-swi
Copy link
Contributor Author

Please add some docker tests, I fixed a crash in the psycopg commenter code extracting the libpq version recently and the mocks were not matching reality.

@xrmx done, ptal.

I tried to add one for the unknown fallback in couple ways that won't work. Attempting a patch in docker-tests results in AttributeError: '_mysql_connector.MySQL' object attribute 'get_client_info' is read-only. Similarly, can't remove _cmysql from mysql.connector at test time. Unit test coverage is adequate I hope.

@tammy-baylis-swi tammy-baylis-swi requested a review from xrmx October 20, 2025 23:22
MYSQL_DB_NAME = os.getenv("MYSQL_DB_NAME", "opentelemetry-tests")


class TestFunctionalMySqlCommenter(TestBase):
Copy link
Member

Choose a reason for hiding this comment

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

Are those tests expected to fail at main? I'm getting everything PASS when pointing to main

SELECT 1 /*db_driver='mysql.connector%%3A8.3.0',dbapi_level='2.0',dbapi_threadsafety=1,driver_paramstyle='pyformat',mysql_client_version='8.3.0',traceparent='00-d0c5771e4343ab1a2f61742f0ec84943-de7c651ef428f35f-01'*/;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No they should pass, which isn't the most comprehensive but I couldn't figure out how to force failure in docker tests -- any ideas? I did cover some fallback scenarios in the unit tests.

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

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

DB-API instrumentation errors if mysql-connector connection wrapper used for queries with sqlcomment enabled

3 participants