From 0baf8d5859656d22475c8b95604efc63b7d6b858 Mon Sep 17 00:00:00 2001 From: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:22:59 -0700 Subject: [PATCH] Develop swap redis asyncio commits (#913) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Redis asyncio testing (#881)" (#911) * Revert "Redis asyncio testing (#881)" This reverts commit 05cff1b6cf0629f7764e46b92c8f2cea2c206dd0. * Add spublish to list of commands * Fix redis.asyncio sync operations wrapper (#782) * Fix redis.asyncio sync operations wrapper * Add clean ups * Fixes: - `loop` -> noqa - catch `TimeoutError` on `asyncio.timeout` * Added separate instrumentation for redis.asyncio.client (#808) * Added separate instrumentation for redis.asyncio.client Merge main branch updates Add tests for newrelic/config.py (#860) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Modify redis tests * removed redis.asyncio from aioredis instrumentation removed aioredis instrumentation in redis asyncio client removed redis.asyncio from aioredis instrumentation --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Lalleh Rafeei Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Modify tests * Tweak tests and instrumentation * Tweak tests to separate aioredis and redis.asyncio * Correctly separate commands to sync/async --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Ahmed Co-authored-by: Lalleh Rafeei Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Remove formatting in import --------- Co-authored-by: Błażej Cyrzon <36710760+bc291@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Ahmed --- newrelic/hooks/datastore_aioredis.py | 3 +-- newrelic/hooks/datastore_redis.py | 2 +- tests/datastore_aioredis/test_execute_command.py | 2 -- tests/datastore_redis/test_asyncio.py | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/newrelic/hooks/datastore_aioredis.py b/newrelic/hooks/datastore_aioredis.py index daced369ab..03c0f0900a 100644 --- a/newrelic/hooks/datastore_aioredis.py +++ b/newrelic/hooks/datastore_aioredis.py @@ -11,7 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - from newrelic.api.datastore_trace import DatastoreTrace from newrelic.api.time_trace import current_trace from newrelic.api.transaction import current_transaction @@ -60,6 +59,7 @@ def _nr_wrapper_AioRedis_method_(wrapped, instance, args, kwargs): # Method will return synchronously without executing, # it will be added to the command stack and run later. aioredis_version = get_package_version_tuple("aioredis") + # This conditional is for versions of aioredis that are outside # New Relic's supportability window but will still work. New # Relic does not provide testing/support for this. In order to @@ -139,7 +139,6 @@ async def wrap_Connection_send_command(wrapped, instance, args, kwargs): ): return await wrapped(*args, **kwargs) - # This wrapper is for versions of aioredis that are outside # New Relic's supportability window but will still work. New # Relic does not provide testing/support for this. In order to diff --git a/newrelic/hooks/datastore_redis.py b/newrelic/hooks/datastore_redis.py index 0f1c522b76..2bfa626840 100644 --- a/newrelic/hooks/datastore_redis.py +++ b/newrelic/hooks/datastore_redis.py @@ -18,6 +18,7 @@ from newrelic.api.transaction import current_transaction from newrelic.common.object_wrapper import function_wrapper, wrap_function_wrapper + _redis_client_sync_methods = { "acl_dryrun", "auth", @@ -612,7 +613,6 @@ def instrument_asyncio_redis_client(module): if hasattr(class_, operation): _wrap_asyncio_Redis_method_wrapper(module, "Redis", operation) - def instrument_redis_commands_core(module): _instrument_redis_commands_module(module, "CoreCommands") diff --git a/tests/datastore_aioredis/test_execute_command.py b/tests/datastore_aioredis/test_execute_command.py index 54851a6592..b600abea5a 100644 --- a/tests/datastore_aioredis/test_execute_command.py +++ b/tests/datastore_aioredis/test_execute_command.py @@ -13,8 +13,6 @@ # limitations under the License. import pytest - -# import aioredis from conftest import AIOREDIS_VERSION, loop # noqa # pylint: disable=E0611,W0611 from testing_support.db_settings import redis_settings from testing_support.fixtures import override_application_settings diff --git a/tests/datastore_redis/test_asyncio.py b/tests/datastore_redis/test_asyncio.py index 5ffdda5829..00aa318783 100644 --- a/tests/datastore_redis/test_asyncio.py +++ b/tests/datastore_redis/test_asyncio.py @@ -104,4 +104,4 @@ async def _test_pubsub(): await future loop.run_until_complete(_test_pubsub()) - assert messages_received == ["Hello", "World", "NOPE"] + assert messages_received == ["Hello", "World", "NOPE"] \ No newline at end of file