Skip to content

Commit

Permalink
Merge branch 'main' into feature-integrate-devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 10, 2023
2 parents 200efcc + 17f8937 commit 725a339
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 82 deletions.
24 changes: 13 additions & 11 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
ignore:
- "newrelic/packages/**/*"
- "newrelic/packages/*"
- "newreilc/hooks/component_sentry.py"
- "newrelic/hooks/adapter_meinheld.py"
- "newrelic/admin/*"
- "newrelic/console.py"
- "newrelic/hooks/adapter_flup.py"
- "newrelic/hooks/adapter_meinheld.py"
- "newrelic/hooks/adapter_paste.py"
- "newrelic/hooks/component_piston.py"
- "newrelic/hooks/database_oursql.py"
- "newrelic/hooks/database_psycopg2ct.py"
- "newrelic/hooks/datastore_aioredis.py"
- "newrelic/hooks/datastore_aredis.py"
- "newrelic/hooks/datastore_motor.py"
- "newrelic/hooks/datastore_pyelasticsearch.py"
- "newrelic/hooks/external_pywapi.py"
- "newrelic/hooks/datastore_umemcache.py"
- "newrelic/hooks/external_dropbox.py"
- "newrelic/hooks/external_facepy.py"
- "newrelic/hooks/external_pywapi.py"
- "newrelic/hooks/external_xmlrpclib.py"
- "newrelic/hooks/framework_pylons.py"
- "newrelic/hooks/framework_web2py.py"
- "newrelic/hooks/middleware_weberror.py"
- "newrelic/hooks/framework_webpy.py"
- "newrelic/hooks/datastore_motor.py"
- "newrelic/hooks/database_oursql.py"
- "newrelic/hooks/database_psycopg2ct.py"
- "newrelic/hooks/datastore_umemcache.py"
- "newrelic/admin/*"
- "newrelic/console.py"
- "newrelic/hooks/middleware_weberror.py"
- "newrelic/packages/*"
- "newrelic/packages/**/*"
6 changes: 4 additions & 2 deletions newrelic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2674,12 +2674,14 @@ def _process_module_builtin_defaults():
"aioredis.connection", "newrelic.hooks.datastore_aioredis", "instrument_aioredis_connection"
)

# Redis v4.2+
_process_module_definition(
"redis.asyncio.client", "newrelic.hooks.datastore_aioredis", "instrument_aioredis_client"
"redis.asyncio.client", "newrelic.hooks.datastore_redis", "instrument_asyncio_redis_client"
)

# Redis v4.2+
_process_module_definition(
"redis.asyncio.commands", "newrelic.hooks.datastore_aioredis", "instrument_aioredis_client"
"redis.asyncio.commands", "newrelic.hooks.datastore_redis", "instrument_asyncio_redis_client"
)

_process_module_definition(
Expand Down
23 changes: 18 additions & 5 deletions newrelic/hooks/datastore_aioredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ 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")
if aioredis_version and aioredis_version < (2,):
# 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
# AioRedis v1 uses a RedisBuffer instead of a real connection for queueing up pipeline commands
from aioredis.commands.transaction import _RedisBuffer

Expand All @@ -72,8 +77,6 @@ def _nr_wrapper_AioRedis_method_(wrapped, instance, args, kwargs):
# AioRedis v2 uses a Pipeline object for a client and internally queues up pipeline commands
if aioredis_version:
from aioredis.client import Pipeline
else:
from redis.asyncio.client import Pipeline
if isinstance(instance, Pipeline):
return wrapped(*args, **kwargs)

Expand Down Expand Up @@ -137,7 +140,12 @@ async def wrap_Connection_send_command(wrapped, instance, args, kwargs):
return await wrapped(*args, **kwargs)


def wrap_RedisConnection_execute(wrapped, instance, 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
# RedisConnection in aioredis v1 returns a future instead of using coroutines
transaction = current_transaction()
if not transaction:
Expand Down Expand Up @@ -205,6 +213,11 @@ def instrument_aioredis_connection(module):
if hasattr(module.Connection, "send_command"):
wrap_function_wrapper(module, "Connection.send_command", wrap_Connection_send_command)

if hasattr(module, "RedisConnection"):
# 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, "execute"):
wrap_function_wrapper(module, "RedisConnection.execute", wrap_RedisConnection_execute)
Loading

0 comments on commit 725a339

Please sign in to comment.