当前位置: 首页>>代码示例>>Python>>正文


Python Pin.override方法代码示例

本文整理汇总了Python中ddtrace.Pin.override方法的典型用法代码示例。如果您正苦于以下问题:Python Pin.override方法的具体用法?Python Pin.override怎么用?Python Pin.override使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ddtrace.Pin的用法示例。


在下文中一共展示了Pin.override方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_pin_config

# 需要导入模块: from ddtrace import Pin [as 别名]
# 或者: from ddtrace.Pin import override [as 别名]
 def test_pin_config(self):
     # ensure `Pin` has a configuration object that can be modified
     obj = self.Obj()
     Pin.override(obj, service='metrics')
     pin = Pin.get_from(obj)
     ok_(pin._config is not None)
     pin._config['distributed_tracing'] = True
     ok_(pin._config['distributed_tracing'] is True)
开发者ID:tebriel,项目名称:dd-trace-py,代码行数:10,代码来源:test_pin.py

示例2: test_override_missing

# 需要导入模块: from ddtrace import Pin [as 别名]
# 或者: from ddtrace.Pin import override [as 别名]
    def test_override_missing(self):
        # ensure overriding an instance doesn't override the Class
        class A(object):
            pass

        a = A()
        ok_(Pin.get_from(a) is None)
        Pin.override(a, service='metrics')
        eq_(Pin.get_from(a).service, 'metrics')

        b = A()
        ok_(Pin.get_from(b) is None)
开发者ID:tebriel,项目名称:dd-trace-py,代码行数:14,代码来源:test_pin.py

示例3: test_override

# 需要导入模块: from ddtrace import Pin [as 别名]
# 或者: from ddtrace.Pin import override [as 别名]
    def test_override(self):
        # ensure Override works for an instance object
        class A(object):
            pass

        Pin(service='metrics', app='flask').onto(A)
        a = A()
        Pin.override(a, app='django')
        eq_(Pin.get_from(a).app, 'django')
        eq_(Pin.get_from(a).service, 'metrics')

        b = A()
        eq_(Pin.get_from(b).app, 'flask')
        eq_(Pin.get_from(b).service, 'metrics')
开发者ID:tebriel,项目名称:dd-trace-py,代码行数:16,代码来源:test_pin.py

示例4: test_pin_config_is_a_copy

# 需要导入模块: from ddtrace import Pin [as 别名]
# 或者: from ddtrace.Pin import override [as 别名]
    def test_pin_config_is_a_copy(self):
        # ensure that when a `Pin` is cloned, the config is a copy
        obj = self.Obj()
        Pin.override(obj, service='metrics')
        p1 = Pin.get_from(obj)
        ok_(p1._config is not None)
        p1._config['distributed_tracing'] = True

        Pin.override(obj, service='intake')
        p2 = Pin.get_from(obj)
        ok_(p2._config is not None)
        p2._config['distributed_tracing'] = False

        ok_(p1._config['distributed_tracing'] is True)
        ok_(p2._config['distributed_tracing'] is False)
开发者ID:tebriel,项目名称:dd-trace-py,代码行数:17,代码来源:test_pin.py

示例5: test_pin_does_not_override_global

# 需要导入模块: from ddtrace import Pin [as 别名]
# 或者: from ddtrace.Pin import override [as 别名]
    def test_pin_does_not_override_global(self):
        # ensure that when a `Pin` is created from a class, the specific
        # instance doesn't override the global one
        class A(object):
            pass

        Pin.override(A, service='metrics')
        global_pin = Pin.get_from(A)
        global_pin._config['distributed_tracing'] = True

        a = A()
        pin = Pin.get_from(a)
        ok_(pin is not None)
        ok_(pin._config['distributed_tracing'] is True)
        pin._config['distributed_tracing'] = False

        ok_(global_pin._config['distributed_tracing'] is True)
        ok_(pin._config['distributed_tracing'] is False)
开发者ID:tebriel,项目名称:dd-trace-py,代码行数:20,代码来源:test_pin.py

示例6: aiobotocore_client

# 需要导入模块: from ddtrace import Pin [as 别名]
# 或者: from ddtrace.Pin import override [as 别名]
def aiobotocore_client(service, tracer):
    """Helper function that creates a new aiobotocore client so that
    it is closed at the end of the context manager.
    """
    session = aiobotocore.session.get_session()
    endpoint = LOCALSTACK_ENDPOINT_URL[service]
    client = session.create_client(
        service,
        region_name='us-west-2',
        endpoint_url=endpoint,
        aws_access_key_id='aws',
        aws_secret_access_key='aws',
        aws_session_token='aws',
    )
    Pin.override(client, tracer=tracer)
    try:
        yield client
    finally:
        client.close()
开发者ID:tebriel,项目名称:dd-trace-py,代码行数:21,代码来源:utils.py

示例7: get_redis_and_tracer

# 需要导入模块: from ddtrace import Pin [as 别名]
# 或者: from ddtrace.Pin import override [as 别名]
 def get_redis_and_tracer(self):
     tracer = get_dummy_tracer()
     r = redis.Redis(port=REDIS_CONFIG['port'])
     Pin.override(r, service=self.TEST_SERVICE, tracer=tracer)
     return r, tracer
开发者ID:tebriel,项目名称:dd-trace-py,代码行数:7,代码来源:test.py


注:本文中的ddtrace.Pin.override方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。