本文整理汇总了Python中opentracing.ext.tags.SPAN_KIND_RPC_CLIENT属性的典型用法代码示例。如果您正苦于以下问题:Python tags.SPAN_KIND_RPC_CLIENT属性的具体用法?Python tags.SPAN_KIND_RPC_CLIENT怎么用?Python tags.SPAN_KIND_RPC_CLIENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类opentracing.ext.tags
的用法示例。
在下文中一共展示了tags.SPAN_KIND_RPC_CLIENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_two_callbacks
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test_two_callbacks(self):
res_future1 = self.loop.create_task(self.client.send('message1'))
res_future2 = self.loop.create_task(self.client.send('message2'))
stop_loop_when(self.loop,
lambda: len(self.tracer.finished_spans()) >= 2)
self.loop.run_forever()
self.assertEquals('message1::response', res_future1.result())
self.assertEquals('message2::response', res_future2.result())
spans = self.tracer.finished_spans()
self.assertEquals(len(spans), 2)
for span in spans:
self.assertEquals(span.tags.get(tags.SPAN_KIND, None),
tags.SPAN_KIND_RPC_CLIENT)
self.assertNotSameTrace(spans[0], spans[1])
self.assertIsNone(spans[0].parent_id)
self.assertIsNone(spans[1].parent_id)
示例2: test_two_callbacks
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test_two_callbacks(self):
res_future1 = self.client.send('message1')
res_future2 = self.client.send('message2')
stop_loop_when(self.loop,
lambda: len(self.tracer.finished_spans()) >= 2)
self.loop.start()
self.assertEquals('message1::response', res_future1.result())
self.assertEquals('message2::response', res_future2.result())
spans = self.tracer.finished_spans()
self.assertEquals(len(spans), 2)
for span in spans:
self.assertEquals(span.tags.get(tags.SPAN_KIND, None),
tags.SPAN_KIND_RPC_CLIENT)
self.assertNotSameTrace(spans[0], spans[1])
self.assertIsNone(spans[0].parent_id)
self.assertIsNone(spans[1].parent_id)
示例3: test_two_callbacks
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test_two_callbacks(self):
res_future1 = self.loop.create_task(self.client.send('message1'))
res_future2 = self.loop.create_task(self.client.send('message2'))
stop_loop_when(self.loop,
lambda: len(self.tracer.finished_spans()) >= 2)
self.loop.run_forever()
self.assertEqual('message1::response', res_future1.result())
self.assertEqual('message2::response', res_future2.result())
spans = self.tracer.finished_spans()
self.assertEqual(len(spans), 2)
for span in spans:
self.assertEqual(span.tags.get(tags.SPAN_KIND, None),
tags.SPAN_KIND_RPC_CLIENT)
self.assertNotSameTrace(spans[0], spans[1])
self.assertIsNone(spans[0].parent_id)
self.assertIsNone(spans[1].parent_id)
示例4: test_two_callbacks
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test_two_callbacks(self):
response_future1 = self.client.send('message1')
response_future2 = self.client.send('message2')
self.assertEquals('message1::response', response_future1.result(5.0))
self.assertEquals('message2::response', response_future2.result(5.0))
spans = self.tracer.finished_spans()
self.assertEquals(len(spans), 2)
for span in spans:
self.assertEquals(span.tags.get(tags.SPAN_KIND, None),
tags.SPAN_KIND_RPC_CLIENT)
self.assertNotSameTrace(spans[0], spans[1])
self.assertIsNone(spans[0].parent_id)
self.assertIsNone(spans[1].parent_id)
示例5: test
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test(self):
client = Client(self.tracer, self.queue)
with tracer_stack_context():
self.loop.add_callback(self.server.run)
self.loop.add_callback(client.send)
stop_loop_when(self.loop,
lambda: len(self.tracer.finished_spans()) >= 2)
self.loop.start()
spans = self.tracer.finished_spans()
self.assertIsNotNone(get_one_by_tag(spans,
tags.SPAN_KIND,
tags.SPAN_KIND_RPC_SERVER))
self.assertIsNotNone(get_one_by_tag(spans,
tags.SPAN_KIND,
tags.SPAN_KIND_RPC_CLIENT))
示例6: test
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test(self):
client = Client(self.tracer, self.queue)
self.loop.create_task(self.server.run())
self.loop.create_task(client.send())
stop_loop_when(self.loop,
lambda: len(self.tracer.finished_spans()) >= 2)
self.loop.run_forever()
spans = self.tracer.finished_spans()
self.assertIsNotNone(get_one_by_tag(spans,
tags.SPAN_KIND,
tags.SPAN_KIND_RPC_SERVER))
self.assertIsNotNone(get_one_by_tag(spans,
tags.SPAN_KIND,
tags.SPAN_KIND_RPC_CLIENT))
示例7: complex
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def complex(request):
with opentracing.tracer.start_active_span('asteroid') as pscope:
pscope.span.set_tag(ext.COMPONENT, "Python simple example app")
pscope.span.set_tag(ext.SPAN_KIND, ext.SPAN_KIND_RPC_SERVER)
pscope.span.set_tag(ext.PEER_HOSTNAME, "localhost")
pscope.span.set_tag(ext.HTTP_URL, "/python/simple/one")
pscope.span.set_tag(ext.HTTP_METHOD, "GET")
pscope.span.set_tag(ext.HTTP_STATUS_CODE, 200)
pscope.span.log_kv({"foo": "bar"})
time.sleep(.2)
with opentracing.tracer.start_active_span('spacedust', child_of=pscope.span) as cscope:
cscope.span.set_tag(ext.SPAN_KIND, ext.SPAN_KIND_RPC_CLIENT)
cscope.span.set_tag(ext.PEER_HOSTNAME, "localhost")
cscope.span.set_tag(ext.HTTP_URL, "/python/simple/two")
cscope.span.set_tag(ext.HTTP_METHOD, "POST")
cscope.span.set_tag(ext.HTTP_STATUS_CODE, 204)
cscope.span.set_baggage_item("someBaggage", "someValue")
time.sleep(.1)
return HttpResponse('Stan wuz here!')
示例8: test_two_callbacks
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test_two_callbacks(self):
response_future1 = self.client.send("message1")
response_future2 = self.client.send("message2")
self.assertEqual("message1::response", response_future1.result(5.0))
self.assertEqual("message2::response", response_future2.result(5.0))
spans = self.tracer.finished_spans()
self.assertEqual(len(spans), 2)
for span in spans:
self.assertEqual(
span.attributes.get(tags.SPAN_KIND, None),
tags.SPAN_KIND_RPC_CLIENT,
)
self.assertNotSameTrace(spans[0], spans[1])
self.assertIsNone(spans[0].parent)
self.assertIsNone(spans[1].parent)
示例9: test
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test(self):
client = Client(self.tracer, self.queue)
self.loop.create_task(self.server.run())
self.loop.create_task(client.send())
stop_loop_when(
self.loop,
lambda: len(self.tracer.finished_spans()) >= 2,
timeout=5.0,
)
self.loop.run_forever()
spans = self.tracer.finished_spans()
self.assertIsNotNone(
get_one_by_tag(spans, tags.SPAN_KIND, tags.SPAN_KIND_RPC_SERVER)
)
self.assertIsNotNone(
get_one_by_tag(spans, tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT)
)
示例10: perform_call
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def perform_call(self, original_func, kind, service_name, operation_name,
*args, **kwargs):
span = utils.start_child_span(
operation_name='boto3:{}:{}:{}'.format(
kind, service_name, operation_name
),
parent=get_current_span()
)
span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT)
span.set_tag(tags.COMPONENT, 'boto3')
span.set_tag('boto3.service_name', service_name)
with span, span_in_stack_context(span):
try:
response = original_func(*args, **kwargs)
except ClientError as error:
self.set_request_id_tag(span, error.response)
raise
else:
if isinstance(response, dict):
self.set_request_id_tag(span, response)
return response
示例11: __call__
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def __call__(self, *args, **kwargs):
safe_kwargs = kwargs
if 'passwd' in kwargs or 'password' in kwargs or 'conv' in kwargs:
safe_kwargs = dict(kwargs)
if 'passwd' in safe_kwargs:
del safe_kwargs['passwd']
if 'password' in safe_kwargs:
del safe_kwargs['password']
if 'conv' in safe_kwargs: # don't log conversion functions
del safe_kwargs['conv']
connect_params = (args, safe_kwargs) if args or safe_kwargs else None
tags = {ext_tags.SPAN_KIND: ext_tags.SPAN_KIND_RPC_CLIENT}
with func_span(self._connect_func_name, tags=tags):
return self._wrapper_ctor(
connection=self._connect_func(*args, **kwargs),
module_name=self._module_name,
connect_params=connect_params,
cursor_wrapper=self._cursor_wrapper)
示例12: test_is_rpc
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test_is_rpc():
mock_tracer = mock.MagicMock()
mock_tracer.max_tag_value_length = 100
ctx = SpanContext(trace_id=1, span_id=2, parent_id=None, flags=1)
span = Span(context=ctx, operation_name='x', tracer=mock_tracer)
assert span.is_rpc() is False
assert span.is_rpc_client() is False
span = Span(context=ctx, operation_name='x', tracer=mock_tracer)
span.set_tag(ext_tags.SPAN_KIND, ext_tags.SPAN_KIND_RPC_SERVER)
assert span.is_rpc() is True
assert span.is_rpc_client() is False
span = Span(context=ctx, operation_name='x', tracer=mock_tracer)
span.set_tag(ext_tags.SPAN_KIND, ext_tags.SPAN_KIND_RPC_CLIENT)
assert span.is_rpc() is True
assert span.is_rpc_client() is True
示例13: test_child_span
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def test_child_span(tracer):
span = tracer.start_span('test')
child = tracer.start_span('child', references=child_of(span.context))
child.set_tag(ext_tags.SPAN_KIND, ext_tags.SPAN_KIND_RPC_CLIENT)
child.set_tag('bender', 'is great')
child.log_event('kiss-my-shiny-metal-...')
child.finish()
span.finish()
tracer.reporter.report_span.assert_called_once()
assert len(span.logs) == 0, 'Parent span is Local, must not have events'
assert len(child.logs) == 1, 'Child must have one events'
tracer.sampler = ConstSampler(False)
span = tracer.start_span('test')
child = tracer.start_span('child', references=child_of(span.context))
child.set_tag('bender', 'is great')
child.log_event('kiss-my-shiny-metal-...')
child.finish()
span.finish()
assert len(child.logs) == 0, 'Must have no events, not sampled'
assert len(child.tags) == 0, 'Must have no attributes, not sampled'
tracer.close()
示例14: before_request
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def before_request(self, request, request_context):
logger.info('Before request %s' % request)
# If we should ignore the active Span, use any passed SpanContext
# as the parent. Else, use the active one.
if self.ignore_active_span:
span = self.tracer.start_span('send',
child_of=self.context,
ignore_active_span=True)
else:
span = self.tracer.start_span('send')
span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT)
request_context['span'] = span
示例15: send_sync
# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND_RPC_CLIENT [as 别名]
def send_sync(self, message):
span = self.tracer.start_span('send')
span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT)
listener = ResponseListener(span)
return self.loop.run_until_complete(self.task(message, listener))