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


Python tags.SPAN_KIND属性代码示例

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


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

示例1: test_two_callbacks

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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) 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:23,代码来源:test_asyncio.py

示例2: test_two_callbacks

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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) 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:23,代码来源:test_tornado.py

示例3: test_two_callbacks

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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) 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:23,代码来源:test_contextvars.py

示例4: test_two_callbacks

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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) 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:19,代码来源:test_threads.py

示例5: test

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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)) 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:18,代码来源:test_asyncio.py

示例6: test

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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)) 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:19,代码来源:test_tornado.py

示例7: _collect_kvs

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [as 别名]
def _collect_kvs(self, span, sql):
        try:
            span.set_tag(ext.SPAN_KIND, 'exit')

            if 'db' in self._connect_params[1]:
                span.set_tag(ext.DATABASE_INSTANCE, self._connect_params[1]['db'])
            elif 'database' in self._connect_params[1]:
                span.set_tag(ext.DATABASE_INSTANCE, self._connect_params[1]['database'])

            span.set_tag(ext.DATABASE_STATEMENT, sql_sanitizer(sql))
            span.set_tag(ext.DATABASE_USER, self._connect_params[1]['user'])
            span.set_tag('host', self._connect_params[1]['host'])
            span.set_tag('port', self._connect_params[1]['port'])
        except Exception as e:
            logger.debug(e)
        finally:
            return span 
开发者ID:instana,项目名称:python-sensor,代码行数:19,代码来源:pep0249.py

示例8: complex

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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!') 
开发者ID:instana,项目名称:python-sensor,代码行数:23,代码来源:app_django.py

示例9: _start_span

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [as 别名]
def _start_span(self, servicer_context, method):
        span_context = None
        error = None
        metadata = servicer_context.invocation_metadata()
        try:
            if metadata:
                span_context = self._tracer.extract(
                    opentracing.Format.HTTP_HEADERS, dict(metadata))
        except (opentracing.UnsupportedFormatException,
                opentracing.InvalidCarrierException,
                opentracing.SpanContextCorruptedException) as e:
            logging.exception('tracer.extract() failed')
            error = e
        tags = {
            ot_tags.COMPONENT: 'grpc',
            ot_tags.SPAN_KIND: ot_tags.SPAN_KIND_RPC_SERVER
        }
        _add_peer_tags(servicer_context.peer(), tags)
        span = self._tracer.start_span(
            operation_name=method, child_of=span_context, tags=tags)
        if error is not None:
            span.log_kv({'event': 'error', 'error.object': error})
        return span 
开发者ID:opentracing-contrib,项目名称:python-grpc,代码行数:25,代码来源:_server.py

示例10: test_two_callbacks

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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) 
开发者ID:open-telemetry,项目名称:opentelemetry-python,代码行数:21,代码来源:test_threads.py

示例11: test

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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)
        ) 
开发者ID:open-telemetry,项目名称:opentelemetry-python,代码行数:21,代码来源:test_asyncio.py

示例12: perform_call

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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 
开发者ID:uber-common,项目名称:opentracing-python-instrumentation,代码行数:26,代码来源:boto3.py

示例13: test_is_rpc

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [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 
开发者ID:jaegertracing,项目名称:jaeger-client-python,代码行数:20,代码来源:test_span.py

示例14: test_start_trace

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [as 别名]
def test_start_trace(tracer):
    assert type(tracer) is Tracer
    with mock.patch.object(random.Random, 'getrandbits') as mock_random, \
            mock.patch('time.time') as mock_timestamp:
        mock_random.return_value = 12345
        mock_timestamp.return_value = 54321

        span = tracer.start_span('test')
        span.set_tag(ext_tags.SPAN_KIND, ext_tags.SPAN_KIND_RPC_SERVER)
        assert span, 'Span must not be nil'
        assert span.tracer == tracer, 'Tracer must be referenced from span'
        assert find_tag(span, 'span.kind') == ext_tags.SPAN_KIND_RPC_SERVER, \
            'Span must be server-side'
        assert span.trace_id == 12345, 'Must match trace_id'
        assert span.is_sampled(), 'Must be sampled'
        assert span.parent_id is None, 'Must not have parent_id (root span)'
        assert span.start_time == 54321, 'Must match timestamp'

        span.finish()
        assert span.end_time is not None, 'Must have end_time defined'
        tracer.reporter.assert_called_once()

    tracer.close() 
开发者ID:jaegertracing,项目名称:jaeger-client-python,代码行数:25,代码来源:test_tracer.py

示例15: test_start_child

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import SPAN_KIND [as 别名]
def test_start_child(tracer, mode):
    root = tracer.start_span('test')
    if mode == 'arg':
        span = tracer.start_span('test', child_of=root.context)
    elif mode == 'ref':
        span = tracer.start_span('test', references=child_of(root.context))
    else:
        raise ValueError('bad mode')
    span.set_tag(ext_tags.SPAN_KIND, ext_tags.SPAN_KIND_RPC_SERVER)
    assert span.is_sampled(), 'Must be sampled'
    assert span.trace_id == root.trace_id, 'Must have the same trace id'
    assert span.parent_id == root.span_id, 'Must inherit parent id'
    span.finish()
    assert span.end_time is not None, 'Must have end_time set'
    tracer.reporter.assert_called_once()
    tracer.close() 
开发者ID:jaegertracing,项目名称:jaeger-client-python,代码行数:18,代码来源:test_tracer.py


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