Skip to content

Commit

Permalink
Revert "Redis asyncio testing (#881)" (#911)
Browse files Browse the repository at this point in the history
* Revert "Redis asyncio testing (#881)"

This reverts commit 05cff1b.

* Add spublish to list of commands
  • Loading branch information
lrafeei committed Aug 25, 2023
1 parent 399c81f commit d7d0968
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 185 deletions.
21 changes: 3 additions & 18 deletions newrelic/hooks/datastore_aioredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,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
# keep functionality without affecting coverage metrics, this
# segment is excluded from coverage analysis.
if aioredis_version and aioredis_version < (2,): # pragma: no cover
if aioredis_version and aioredis_version < (2,):
# AioRedis v1 uses a RedisBuffer instead of a real connection for queueing up pipeline commands
from aioredis.commands.transaction import _RedisBuffer

Expand Down Expand Up @@ -140,12 +135,7 @@ 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
# keep functionality without affecting coverage metrics, this
# segment is excluded from coverage analysis.
def wrap_RedisConnection_execute(wrapped, instance, args, kwargs): # pragma: no cover
def wrap_RedisConnection_execute(wrapped, instance, args, kwargs):
# RedisConnection in aioredis v1 returns a future instead of using coroutines
transaction = current_transaction()
if not transaction:
Expand Down Expand Up @@ -213,11 +203,6 @@ def instrument_aioredis_connection(module):
if hasattr(module.Connection, "send_command"):
wrap_function_wrapper(module, "Connection.send_command", wrap_Connection_send_command)

# 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
# keep functionality without affecting coverage metrics, this
# segment is excluded from coverage analysis.
if hasattr(module, "RedisConnection"): # pragma: no cover
if hasattr(module, "RedisConnection"):
if hasattr(module.RedisConnection, "execute"):
wrap_function_wrapper(module, "RedisConnection.execute", wrap_RedisConnection_execute)
113 changes: 53 additions & 60 deletions newrelic/hooks/datastore_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,65 +18,10 @@
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",
"bgrewriteaof",
"bitfield",
"blmpop",
"bzmpop",
"client",
"command",
"command_docs",
"command_getkeysandflags",
"command_info",
"debug_segfault",
"expiretime",
"failover",
"hello",
"latency_doctor",
"latency_graph",
"latency_histogram",
"lcs",
"lpop",
"lpos",
"memory_doctor",
"memory_help",
"monitor",
"pexpiretime",
"psetex",
"psync",
"pubsub",
"renamenx",
"rpop",
"script_debug",
"sentinel_ckquorum",
"sentinel_failover",
"sentinel_flushconfig",
"sentinel_get_master_addr_by_name",
"sentinel_master",
"sentinel_masters",
"sentinel_monitor",
"sentinel_remove",
"sentinel_reset",
"sentinel_sentinels",
"sentinel_set",
"sentinel_slaves",
"shutdown",
"sort",
"sort_ro",
"spop",
"srandmember",
"unwatch",
"watch",
"zlexcount",
"zrevrangebyscore",
}


_redis_client_async_methods = {
_redis_client_methods = {
"acl_cat",
"acl_deluser",
"acl_dryrun",
"acl_genpass",
"acl_getuser",
"acl_help",
Expand Down Expand Up @@ -105,8 +50,11 @@
"arrlen",
"arrpop",
"arrtrim",
"auth",
"bgrewriteaof",
"bgsave",
"bitcount",
"bitfield",
"bitfield_ro",
"bitop_and",
"bitop_not",
Expand All @@ -115,11 +63,13 @@
"bitop",
"bitpos",
"blmove",
"blmpop",
"blpop",
"brpop",
"brpoplpush",
"byrank",
"byrevrank",
"bzmpop",
"bzpopmax",
"bzpopmin",
"card",
Expand All @@ -140,6 +90,7 @@
"client_trackinginfo",
"client_unblock",
"client_unpause",
"client",
"cluster_add_slots",
"cluster_addslots",
"cluster_count_failure_report",
Expand Down Expand Up @@ -167,7 +118,10 @@
"cluster_slots",
"cluster",
"command_count",
"command_docs",
"command_getkeys",
"command_getkeysandflags",
"command_info",
"command_list",
"command",
"commit",
Expand All @@ -183,6 +137,7 @@
"createrule",
"dbsize",
"debug_object",
"debug_segfault",
"debug_sleep",
"debug",
"decr",
Expand All @@ -205,8 +160,10 @@
"exists",
"expire",
"expireat",
"expiretime",
"explain_cli",
"explain",
"failover",
"fcall_ro",
"fcall",
"flushall",
Expand Down Expand Up @@ -236,6 +193,7 @@
"getrange",
"getset",
"hdel",
"hello",
"hexists",
"hget",
"hgetall",
Expand Down Expand Up @@ -263,9 +221,13 @@
"insertnx",
"keys",
"lastsave",
"latency_doctor",
"latency_graph",
"latency_histogram",
"latency_history",
"latency_latest",
"latency_reset",
"lcs",
"lindex",
"linsert",
"list",
Expand All @@ -274,6 +236,8 @@
"lmpop",
"loadchunk",
"lolwut",
"lpop",
"lpos",
"lpush",
"lpushx",
"lrange",
Expand All @@ -282,6 +246,8 @@
"ltrim",
"madd",
"max",
"memory_doctor",
"memory_help",
"memory_malloc_stats",
"memory_purge",
"memory_stats",
Expand All @@ -296,6 +262,7 @@
"module_load",
"module_loadex",
"module_unload",
"monitor",
"move",
"mrange",
"mrevrange",
Expand All @@ -311,19 +278,23 @@
"persist",
"pexpire",
"pexpireat",
"pexpiretime",
"pfadd",
"pfcount",
"pfmerge",
"ping",
"profile",
"psetex",
"psubscribe",
"psync",
"pttl",
"publish",
"pubsub_channels",
"pubsub_numpat",
"pubsub_numsub",
"pubsub_shardchannels",
"pubsub_shardnumsub",
"pubsub",
"punsubscribe",
"quantile",
"query",
Expand All @@ -335,6 +306,7 @@
"readonly",
"readwrite",
"rename",
"renamenx",
"replicaof",
"reserve",
"reset",
Expand All @@ -343,6 +315,7 @@
"revrange",
"revrank",
"role",
"rpop",
"rpoplpush",
"rpush",
"rpushx",
Expand All @@ -352,6 +325,7 @@
"scan",
"scandump",
"scard",
"script_debug",
"script_exists",
"script_flush",
"script_kill",
Expand All @@ -360,11 +334,24 @@
"sdiffstore",
"search",
"select",
"sentinel_ckquorum",
"sentinel_failover",
"sentinel_flushconfig",
"sentinel_get_master_addr_by_name",
"sentinel_master",
"sentinel_masters",
"sentinel_monitor",
"sentinel_remove",
"sentinel_reset",
"sentinel_sentinels",
"sentinel_set",
"sentinel_slaves",
"set",
"setbit",
"setex",
"setnx",
"setrange",
"shutdown",
"sinter",
"sintercard",
"sinterstore",
Expand All @@ -377,8 +364,12 @@
"smembers",
"smismember",
"smove",
"sort_ro",
"sort",
"spellcheck",
"spublish",
"spop",
"srandmember",
"srem",
"sscan_iter",
"sscan",
Expand Down Expand Up @@ -411,8 +402,10 @@
"type",
"unlink",
"unsubscribe",
"unwatch",
"wait",
"waitaof",
"watch",
"xack",
"xadd",
"xautoclaim",
Expand Down Expand Up @@ -448,6 +441,7 @@
"zinter",
"zintercard",
"zinterstore",
"zlexcount",
"zmpop",
"zmscore",
"zpopmax",
Expand All @@ -464,6 +458,7 @@
"zremrangebyscore",
"zrevrange",
"zrevrangebylex",
"zrevrangebyscore",
"zrevrank",
"zscan_iter",
"zscan",
Expand All @@ -472,8 +467,6 @@
"zunionstore",
}

_redis_client_methods = _redis_client_sync_methods.union(_redis_client_async_methods)

_redis_multipart_commands = set(["client", "cluster", "command", "config", "debug", "sentinel", "slowlog", "script"])

_redis_operation_re = re.compile(r"[-\s]+")
Expand Down Expand Up @@ -608,7 +601,7 @@ def instrument_redis_client(module):
def instrument_asyncio_redis_client(module):
if hasattr(module, "Redis"):
class_ = getattr(module, "Redis")
for operation in _redis_client_async_methods:
for operation in _redis_client_methods:
if hasattr(class_, operation):
_wrap_asyncio_Redis_method_wrapper(module, "Redis", operation)

Expand Down
Loading

0 comments on commit d7d0968

Please sign in to comment.