From dab664c06ece93eac75c81aa84d5666887d17a1a Mon Sep 17 00:00:00 2001 From: Omar Abdelkader Date: Wed, 31 Jul 2024 13:20:08 -0400 Subject: [PATCH] feat(mysql): add support for mysql-connector-python v9 (#2751) --- CHANGELOG.md | 1 + instrumentation/README.md | 2 +- .../pyproject.toml | 2 +- .../instrumentation/mysql/package.py | 2 +- ...-requirements.txt => test-requirements-0.txt} | 0 .../test-requirements-1.txt | 16 ++++++++++++++++ .../instrumentation/bootstrap_gen.py | 2 +- tox.ini | 12 +++++++++--- 8 files changed, 30 insertions(+), 7 deletions(-) rename instrumentation/opentelemetry-instrumentation-mysql/{test-requirements.txt => test-requirements-0.txt} (100%) create mode 100644 instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b09c75064..0d1f17c43e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#2610](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2610)) - `opentelemetry-instrumentation-asgi` Bugfix: Middleware did not set status code attribute on duration metrics for non-recording spans. ([#2627](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2627)) +- `opentelemetry-instrumentation-mysql` Add support for `mysql-connector-python` v9 ([#2751](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2751)) ## Version 1.25.0/0.46b0 (2024-05-31) diff --git a/instrumentation/README.md b/instrumentation/README.md index 20438e0a12..278182e61f 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -26,7 +26,7 @@ | [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 | No | experimental | [opentelemetry-instrumentation-kafka-python](./opentelemetry-instrumentation-kafka-python) | kafka-python >= 2.0 | No | experimental | [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging | No | experimental -| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | No | experimental +| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python >= 8.0, < 10.0 | No | experimental | [opentelemetry-instrumentation-mysqlclient](./opentelemetry-instrumentation-mysqlclient) | mysqlclient < 3 | No | experimental | [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 | No | experimental | [opentelemetry-instrumentation-psycopg](./opentelemetry-instrumentation-psycopg) | psycopg >= 3.1.0 | No | experimental diff --git a/instrumentation/opentelemetry-instrumentation-mysql/pyproject.toml b/instrumentation/opentelemetry-instrumentation-mysql/pyproject.toml index cb1c51b082..3c7d0c9166 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-mysql/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ [project.optional-dependencies] instruments = [ - "mysql-connector-python ~= 8.0", + "mysql-connector-python >= 8.0, < 10.0", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/package.py b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/package.py index efb8ece73b..4d84c1161b 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/package.py +++ b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/package.py @@ -13,4 +13,4 @@ # limitations under the License. -_instruments = ("mysql-connector-python ~= 8.0",) +_instruments = ("mysql-connector-python >= 8.0, < 10.0",) diff --git a/instrumentation/opentelemetry-instrumentation-mysql/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-0.txt similarity index 100% rename from instrumentation/opentelemetry-instrumentation-mysql/test-requirements.txt rename to instrumentation/opentelemetry-instrumentation-mysql/test-requirements-0.txt diff --git a/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt new file mode 100644 index 0000000000..dd609e594a --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt @@ -0,0 +1,16 @@ +asgiref==3.7.2 +Deprecated==1.2.14 +importlib-metadata==6.11.0 +iniconfig==2.0.0 +mysql-connector-python==9.0.0 +packaging==24.0 +pluggy==1.5.0 +py-cpuinfo==9.0.0 +pytest==7.4.4 +tomli==2.0.1 +typing_extensions==4.9.0 +wrapt==1.16.0 +zipp==3.19.2 +-e opentelemetry-instrumentation +-e instrumentation/opentelemetry-instrumentation-dbapi +-e instrumentation/opentelemetry-instrumentation-mysql diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index 4ad6824281..0deb99b8bf 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -109,7 +109,7 @@ "instrumentation": "opentelemetry-instrumentation-kafka-python==0.48b0.dev", }, { - "library": "mysql-connector-python ~= 8.0", + "library": "mysql-connector-python >= 8.0, < 10.0", "instrumentation": "opentelemetry-instrumentation-mysql==0.48b0.dev", }, { diff --git a/tox.ini b/tox.ini index 028db9c19f..5e433d5bb4 100644 --- a/tox.ini +++ b/tox.ini @@ -177,8 +177,12 @@ envlist = lint-exporter-prometheus-remote-write ; opentelemetry-instrumentation-mysql - py3{8,9,10,11,12}-test-instrumentation-mysql - pypy3-test-instrumentation-mysql + ; The numbers at the end of the environment names + ; below mean these dependencies are being used: + ; 0: mysql-connector-python >=8.0.0,<9.0.0 + ; 1: mysql-connector-python ~=9.0.0 + py3{8,9,10,11,12}-test-instrumentation-mysql-{0,1} + pypy3-test-instrumentation-mysql-{0,1} lint-instrumentation-mysql ; opentelemetry-instrumentation-mysqlclient @@ -562,7 +566,9 @@ commands_pre = mysql: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions mysql: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk mysql: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils - mysql: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-mysql/test-requirements.txt + mysql-0: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-0.txt + mysql-1: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt + lint-instrumentation-mysql: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt mysqlclient: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api mysqlclient: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions