From dffbb97c6e9076d47c1e3b5d3da3e81fbcceb85e Mon Sep 17 00:00:00 2001 From: Phillip Verheyden Date: Tue, 14 Feb 2023 12:07:48 -0600 Subject: [PATCH] Support aio_pika 9 --- CHANGELOG.md | 1 + instrumentation/README.md | 2 +- .../pyproject.toml | 2 +- .../instrumentation/aio_pika/package.py | 2 +- .../tests/consts.py | 2 ++ .../tests/test_callback_decorator.py | 7 ++++--- .../tests/test_publish_decorator.py | 7 ++++--- .../tests/testdb | Bin 0 -> 8192 bytes .../instrumentation/bootstrap_gen.py | 2 +- tox.ini | 9 +++++---- 10 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 instrumentation/opentelemetry-instrumentation-sqlite3/tests/testdb diff --git a/CHANGELOG.md b/CHANGELOG.md index 5680e5fe3c..52c5df9902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Support `aio_pika` 9.x (([#1670](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1670]) - `opentelemetry-instrumentation-redis` Add `sanitize_query` config option to allow query sanitization. ([#1572](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1572)) - `opentelemetry-instrumentation-elasticsearch` Add optional db.statement query sanitization. ([#1598](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1598)) diff --git a/instrumentation/README.md b/instrumentation/README.md index 052d2ba67d..aa71744761 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -1,7 +1,7 @@ | Instrumentation | Supported Packages | Metrics support | | --------------- | ------------------ | --------------- | -| [opentelemetry-instrumentation-aio-pika](./opentelemetry-instrumentation-aio-pika) | aio_pika >= 7.2.0, < 9.0.0 | No +| [opentelemetry-instrumentation-aio-pika](./opentelemetry-instrumentation-aio-pika) | aio_pika >= 7.2.0, < 10.0.0 | No | [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | No | [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 2.0.0 | No | [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | No diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml b/instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml index 994642e22a..1f9a7a7217 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml @@ -31,7 +31,7 @@ dependencies = [ [project.optional-dependencies] instruments = [ - "aio_pika >= 7.2.0, < 9.0.0", + "aio_pika >= 7.2.0, < 10.0.0", ] test = [ "opentelemetry-instrumentation-aio-pika[instruments]", diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/package.py b/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/package.py index 285e9f99cb..8069323f7c 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/package.py +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/package.py @@ -13,4 +13,4 @@ # limitations under the License. from typing import Collection -_instruments: Collection[str] = ("aio_pika >= 7.2.0, < 9.0.0",) +_instruments: Collection[str] = ("aio_pika >= 7.2.0, < 10.0.0",) diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/tests/consts.py b/instrumentation/opentelemetry-instrumentation-aio-pika/tests/consts.py index 7e34c73c63..431780ae7b 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/tests/consts.py +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/tests/consts.py @@ -1,7 +1,9 @@ from argparse import Namespace +from aio_pika import __version__ as aiopika_version from yarl import URL +AIOPIKA_VERSION_INFO = tuple(int(v) for v in aiopika_version.split(".")) MESSAGE_ID = "meesage_id" CORRELATION_ID = "correlation_id" MESSAGING_SYSTEM = "rabbitmq" diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_callback_decorator.py b/instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_callback_decorator.py index 7c9288a657..39a7724bfa 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_callback_decorator.py +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_callback_decorator.py @@ -14,7 +14,7 @@ import asyncio from unittest import TestCase, mock, skipIf -from aio_pika import Queue, version_info +from aio_pika import Queue from opentelemetry.instrumentation.aio_pika.callback_decorator import ( CallbackDecorator, @@ -23,6 +23,7 @@ from opentelemetry.trace import SpanKind, get_tracer from .consts import ( + AIOPIKA_VERSION_INFO, CHANNEL_7, CHANNEL_8, CORRELATION_ID, @@ -36,7 +37,7 @@ ) -@skipIf(version_info >= (8, 0), "Only for aio_pika 7") +@skipIf(AIOPIKA_VERSION_INFO >= (8, 0), "Only for aio_pika 7") class TestInstrumentedQueueAioRmq7(TestCase): EXPECTED_ATTRIBUTES = { SpanAttributes.MESSAGING_SYSTEM: MESSAGING_SYSTEM, @@ -76,7 +77,7 @@ def test_decorate_callback(self): callback.assert_called_once_with(MESSAGE) -@skipIf(version_info <= (8, 0), "Only for aio_pika 8") +@skipIf(AIOPIKA_VERSION_INFO <= (8, 0), "Only for aio_pika 8") class TestInstrumentedQueueAioRmq8(TestCase): EXPECTED_ATTRIBUTES = { SpanAttributes.MESSAGING_SYSTEM: MESSAGING_SYSTEM, diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_publish_decorator.py b/instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_publish_decorator.py index e5586b9a00..d5291e07d9 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_publish_decorator.py +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_publish_decorator.py @@ -15,7 +15,7 @@ from typing import Type from unittest import TestCase, mock, skipIf -from aio_pika import Exchange, RobustExchange, version_info +from aio_pika import Exchange, RobustExchange from opentelemetry.instrumentation.aio_pika.publish_decorator import ( PublishDecorator, @@ -24,6 +24,7 @@ from opentelemetry.trace import SpanKind, get_tracer from .consts import ( + AIOPIKA_VERSION_INFO, CHANNEL_7, CHANNEL_8, CONNECTION_7, @@ -39,7 +40,7 @@ ) -@skipIf(version_info >= (8, 0), "Only for aio_pika 7") +@skipIf(AIOPIKA_VERSION_INFO >= (8, 0), "Only for aio_pika 7") class TestInstrumentedExchangeAioRmq7(TestCase): EXPECTED_ATTRIBUTES = { SpanAttributes.MESSAGING_SYSTEM: MESSAGING_SYSTEM, @@ -92,7 +93,7 @@ def test_robust_publish(self): self._test_publish(RobustExchange) -@skipIf(version_info <= (8, 0), "Only for aio_pika 8") +@skipIf(AIOPIKA_VERSION_INFO <= (8, 0), "Only for aio_pika 8") class TestInstrumentedExchangeAioRmq8(TestCase): EXPECTED_ATTRIBUTES = { SpanAttributes.MESSAGING_SYSTEM: MESSAGING_SYSTEM, diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/tests/testdb b/instrumentation/opentelemetry-instrumentation-sqlite3/tests/testdb new file mode 100644 index 0000000000000000000000000000000000000000..e7584e9d7a4713ed847ea7057a8a300b7a9ee97b GIT binary patch literal 8192 zcmeI#y$ZrG6o%n*inxg`#r2H3IOq*nC7{qnEjU+g1`E9ns)QJ^b-US WKmY**5I_I{1Q0*~0R#~EV}TD4au_cF literal 0 HcmV?d00001 diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index b06bdba635..d407053396 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -17,7 +17,7 @@ libraries = { "aio_pika": { - "library": "aio_pika >= 7.2.0, < 9.0.0", + "library": "aio_pika >= 7.2.0, < 10.0.0", "instrumentation": "opentelemetry-instrumentation-aio-pika==0.37b0.dev", }, "aiohttp": { diff --git a/tox.ini b/tox.ini index e51515f906..6f75ec2d6c 100644 --- a/tox.ini +++ b/tox.ini @@ -207,8 +207,8 @@ envlist = pypy3-test-instrumentation-pika{0,1} ; opentelemetry-instrumentation-aio-pika - py3{7,8,9,10,11}-test-instrumentation-aio-pika{7,8} - pypy3-test-instrumentation-aio-pika{7,8} + py3{7,8,9,10,11}-test-instrumentation-aio-pika{7,8,9} + pypy3-test-instrumentation-aio-pika{7,8,9} ; opentelemetry-instrumentation-kafka-python py3{7,8,9,10,11}-test-instrumentation-kafka-python @@ -256,6 +256,7 @@ deps = pika1: pika>=1.0.0 aio-pika7: aio_pika~=7.2.0 aio-pika8: aio_pika>=8.0.0,<9.0.0 + aio-pika9: aio_pika>=9.0.0,<10.0.0 pymemcache135: pymemcache ==1.3.5 pymemcache200: pymemcache >2.0.0,<3.0.0 pymemcache300: pymemcache >3.0.0,<3.4.2 @@ -302,7 +303,7 @@ changedir = test-instrumentation-logging: instrumentation/opentelemetry-instrumentation-logging/tests test-instrumentation-mysql: instrumentation/opentelemetry-instrumentation-mysql/tests test-instrumentation-pika{0,1}: instrumentation/opentelemetry-instrumentation-pika/tests - test-instrumentation-aio-pika{7,8}: instrumentation/opentelemetry-instrumentation-aio-pika/tests + test-instrumentation-aio-pika{7,8,9}: instrumentation/opentelemetry-instrumentation-aio-pika/tests test-instrumentation-psycopg2: instrumentation/opentelemetry-instrumentation-psycopg2/tests test-instrumentation-pymemcache{135,200,300,342}: instrumentation/opentelemetry-instrumentation-pymemcache/tests test-instrumentation-pymongo: instrumentation/opentelemetry-instrumentation-pymongo/tests @@ -344,7 +345,7 @@ commands_pre = pika{0,1}: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-pika[test] - aio-pika{7,8}: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-aio-pika[test] + aio-pika{7,8,9}: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-aio-pika[test] kafka-python: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-kafka-python[test]