def patch():
"""Patch the instrumented methods
This duplicated doesn't look nice. The nicer alternative is to use an ObjectProxy on top
of Redis and StrictRedis. However, it means that any "import redis.Redis" won't be instrumented.
"""
if getattr(redis, '_datadog_patch', False):
return
setattr(redis, '_datadog_patch', True)
_w = wrapt.wrap_function_wrapper
_w('redis', 'StrictRedis.execute_command', traced_execute_command)
_w('redis', 'StrictRedis.pipeline', traced_pipeline)
_w('redis', 'Redis.pipeline', traced_pipeline)
_w('redis.client', 'BasePipeline.execute', traced_execute_pipeline)
_w('redis.client', 'BasePipeline.immediate_execute_command', traced_execute_command)
Pin(service="redis", app="redis", app_type="db").onto(redis.StrictRedis)
评论列表
文章目录