patch.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:dd-trace-py 作者: DataDog 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号