Skip to content

Commit

Permalink
Add new redis commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hmstepanek committed Aug 7, 2024
1 parent 60fe0b6 commit ee15710
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions newrelic/hooks/datastore_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@

import re

from newrelic.api.datastore_trace import DatastoreTrace, DatastoreTraceWrapper, wrap_datastore_trace
from newrelic.api.datastore_trace import (
DatastoreTrace,
DatastoreTraceWrapper,
wrap_datastore_trace,
)
from newrelic.api.time_trace import current_trace
from newrelic.api.transaction import current_transaction
from newrelic.common.async_wrapper import (
async_generator_wrapper,
coroutine_wrapper,
generator_wrapper,
)
from newrelic.common.object_wrapper import wrap_function_wrapper
from newrelic.common.async_wrapper import coroutine_wrapper, async_generator_wrapper, generator_wrapper

_redis_client_sync_methods = {
"acl_dryrun",
Expand All @@ -36,6 +44,15 @@
"expiretime",
"failover",
"hello",
"hexpire",
"hexpireat",
"hexpiretime",
"hpersist",
"hpexpire",
"hpexpireat",
"hpexpiretime",
"hpttl",
"httl",
"latency_doctor",
"latency_graph",
"latency_histogram",
Expand Down Expand Up @@ -523,7 +540,9 @@ def _nr_wrapper_asyncio_Redis_method_(wrapped, instance, args, kwargs):
return wrapped(*args, **kwargs)

# Method should be run when awaited or iterated, therefore we wrap in an async wrapper.
return DatastoreTraceWrapper(wrapped, product="Redis", target=None, operation=operation, async_wrapper=async_wrapper)(*args, **kwargs)
return DatastoreTraceWrapper(
wrapped, product="Redis", target=None, operation=operation, async_wrapper=async_wrapper
)(*args, **kwargs)

name = "%s.%s" % (instance_class_name, operation)
if operation in _redis_client_gen_methods:
Expand Down Expand Up @@ -663,6 +682,7 @@ 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")

Expand Down

0 comments on commit ee15710

Please sign in to comment.