本文整理汇总了Python中jaeger_client.Config方法的典型用法代码示例。如果您正苦于以下问题:Python jaeger_client.Config方法的具体用法?Python jaeger_client.Config怎么用?Python jaeger_client.Config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jaeger_client
的用法示例。
在下文中一共展示了jaeger_client.Config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_tracer
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def init_tracer():
"""Initialize the tracing system."""
config = Config(
config={ # usually read from some yaml config
'enabled': True,
'sampler': {
'type': 'const',
'param': 1,
},
'logging': True,
},
service_name='todo-service',
validate=True,
)
return config.initialize_tracer()
开发者ID:PacktPublishing,项目名称:Hands-On-Enterprise-Application-Development-with-Python,代码行数:18,代码来源:todo_service.py
示例2: init_tracer
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def init_tracer(service):
config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'local_agent': {
'reporting_host': "jaeger",
'reporting_port': 5775,
},
'logging': True,
'reporter_batch_size': 1,
},
service_name=service,
)
# this call also sets opentracing.tracer
return config.initialize_tracer()
示例3: test_throttler
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def test_throttler(self):
c = Config({
'throttler': {}
}, service_name='x')
assert not c.throttler_group()
assert c.throttler_port == DEFAULT_THROTTLER_PORT
assert c.throttler_refresh_interval == constants.DEFAULT_THROTTLER_REFRESH_INTERVAL
c = Config({
'throttler': {
'port': '1234',
'refresh_interval': '10'
}
}, service_name='x')
assert c.throttler_group()
assert c.throttler_port == 1234
assert c.throttler_refresh_interval == 10
c = Config({}, service_name='x')
assert c.throttler_group() is None
assert c.throttler_port is None
assert c.throttler_refresh_interval is None
示例4: test_generate_128bit_trace_id
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def test_generate_128bit_trace_id(self):
c = Config({}, service_name='x')
assert c.generate_128bit_trace_id is False
c = Config({'generate_128bit_trace_id': True}, service_name='x')
assert c.generate_128bit_trace_id is True
os.environ['JAEGER_TRACEID_128BIT'] = 'true'
c = Config({'generate_128bit_trace_id': False}, service_name='x')
assert c.generate_128bit_trace_id is False
c = Config({}, service_name='x')
assert c.generate_128bit_trace_id is True
os.environ.pop('JAEGER_TRACEID_128BIT')
assert os.getenv('JAEGER_TRACEID_128BIT', None) is None
示例5: init_jaeger_tracer
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def init_jaeger_tracer() -> Tracer:
config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'logging': True,
'propagation': "b3",
'local_agent': {
'reporting_host': 'localhost'
}
},
service_name='service2',
validate=True,
scope_manager=AsyncioScopeManager()
)
return config.initialize_tracer()
示例6: init_jaeger_tracer
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def init_jaeger_tracer() -> Tracer:
config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'logging': True,
'propagation': "b3",
'local_agent': {
'reporting_host': 'localhost'
}
},
service_name='service1',
validate=True,
scope_manager=ThreadLocalScopeManager()
)
return config.initialize_tracer()
示例7: init_jaeger_tracer
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def init_jaeger_tracer() -> Tracer:
config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'logging': True,
'propagation': "b3",
'local_agent': {
'reporting_host': 'localhost'
}
},
service_name='service1',
validate=True,
scope_manager=AsyncioScopeManager()
)
return config.initialize_tracer()
示例8: setup_opentracing
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def setup_opentracing(app):
"""
Helper function to setup opentracing with Jaeger client during setup.
Use during app startup as follows:
.. code-block:: python
app = FastAPI()
@app.on_event('startup')
async def startup():
setup_opentracing(app)
:param app: app object, instance of FastAPI
:return: None
"""
config = Config(
config={
"local_agent": {
"reporting_host": settings.jaeger_host,
"reporting_port": settings.jaeger_port
},
"sampler": {
"type": settings.jaeger_sampler_type,
"param": settings.jaeger_sampler_rate,
},
"trace_id_header": settings.trace_id_header
},
service_name=settings.service_name,
validate=True,
scope_manager=AsyncioScopeManager()
)
# this call also sets opentracing.tracer
app.tracer = config.initialize_tracer()
示例9: init_jaeger_tracer
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def init_jaeger_tracer(service_name='proto.example.lifecycle_events'):
config = Config(config={'sampler': {
'type': 'const',
'param': 1,
},
'logging': True, }, service_name=service_name, validate=True)
return config.initialize_tracer()
示例10: init_jaeger_tracer
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def init_jaeger_tracer(service_name='proto.chat.client'):
config = Config(config={'sampler': {
'type': 'const',
'param': 1,
},
'logging': True, }, service_name=service_name, validate=True)
return config.initialize_tracer()
示例11: init_jaeger_tracer
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def init_jaeger_tracer(service_name='proto.chat.server'):
config = Config(config={'sampler': {
'type': 'const',
'param': 1,
},
'logging': True, }, service_name=service_name, validate=True)
return config.initialize_tracer()
示例12: run
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def run():
parser = argparse.ArgumentParser()
parser.add_argument(
'--log_payloads',
action='store_true',
help='log request/response objects to open-tracing spans')
args = parser.parse_args()
config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'logging': True,
},
service_name='integration-client')
tracer = config.initialize_tracer()
active_span_source = FixedActiveSpanSource()
tracer_interceptor = open_tracing_client_interceptor(
tracer,
active_span_source=active_span_source,
log_payloads=args.log_payloads)
channel = grpc.insecure_channel('localhost:50051')
channel = intercept_channel(channel, tracer_interceptor)
stub = command_line_pb2.CommandLineStub(channel)
echo(tracer, active_span_source, stub)
time.sleep(2)
tracer.close()
time.sleep(2)
示例13: serve
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def serve():
parser = argparse.ArgumentParser()
parser.add_argument(
'--log_payloads',
action='store_true',
help='log request/response objects to open-tracing spans')
args = parser.parse_args()
config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'logging': True,
},
service_name='integration-server')
tracer = config.initialize_tracer()
tracer_interceptor = open_tracing_server_interceptor(
tracer, log_payloads=args.log_payloads)
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
server = intercept_server(server, tracer_interceptor)
command_line_pb2.add_CommandLineServicer_to_server(
CommandLine(tracer), server)
server.add_insecure_port('[::]:50051')
server.start()
try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
server.stop(0)
time.sleep(2)
tracer.close()
time.sleep(2)
示例14: run
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def run():
parser = argparse.ArgumentParser()
parser.add_argument(
'--log_payloads',
action='store_true',
help='log request/response objects to open-tracing spans')
args = parser.parse_args()
config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'logging': True,
},
service_name='trivial-client')
tracer = config.initialize_tracer()
tracer_interceptor = open_tracing_client_interceptor(
tracer, log_payloads=args.log_payloads)
channel = grpc.insecure_channel('localhost:50051')
channel = intercept_channel(channel, tracer_interceptor)
stub = command_line_pb2.CommandLineStub(channel)
response = stub.Echo(command_line_pb2.CommandRequest(text='Hello, hello'))
print(response.text)
time.sleep(2)
tracer.close()
time.sleep(2)
示例15: serve
# 需要导入模块: import jaeger_client [as 别名]
# 或者: from jaeger_client import Config [as 别名]
def serve():
parser = argparse.ArgumentParser()
parser.add_argument(
'--log_payloads',
action='store_true',
help='log request/response objects to open-tracing spans')
args = parser.parse_args()
config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'logging': True,
},
service_name='trivial-server')
tracer = config.initialize_tracer()
tracer_interceptor = open_tracing_server_interceptor(
tracer, log_payloads=args.log_payloads)
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
server = intercept_server(server, tracer_interceptor)
command_line_pb2.add_CommandLineServicer_to_server(CommandLine(), server)
server.add_insecure_port('[::]:50051')
server.start()
try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
server.stop(0)
time.sleep(2)
tracer.close()
time.sleep(2)