本文整理汇总了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)
示例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)
示例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')
示例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)
示例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)
示例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()
示例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