當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。