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


Python tags.COMPONENT属性代码示例

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


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

示例1: resolve

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def resolve(
        self, next_: Resolver, parent: Any, info: GraphQLResolveInfo, **kwargs
    ):  # pylint: disable=invalid-overridden-method
        if not should_trace(info):
            result = next_(parent, info, **kwargs)
            return result

        with self._tracer.start_active_span(info.field_name) as scope:
            span = scope.span
            span.set_tag(tags.COMPONENT, "graphql")
            span.set_tag("graphql.parentType", info.parent_type.name)

            graphql_path = ".".join(
                map(str, format_path(info.path))  # pylint: disable=bad-builtin
            )
            span.set_tag("graphql.path", graphql_path)

            if kwargs:
                filtered_kwargs = self.filter_resolver_args(kwargs, info)
                for kwarg, value in filtered_kwargs.items():
                    span.set_tag(f"graphql.param.{kwarg}", value)

            result = next_(parent, info, **kwargs)
            return result 
开发者ID:mirumee,项目名称:ariadne,代码行数:26,代码来源:opentracing.py

示例2: complex

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [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

示例3: _start_span

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [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

示例4: perform_call

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [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

示例5: test_opentracing_extension_sets_graphql_component_tag_on_root_span

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def test_opentracing_extension_sets_graphql_component_tag_on_root_span(
    schema, active_span_mock
):
    graphql(
        schema,
        {"query": '{ status hello(name: "Bob") }'},
        extensions=[OpenTracingExtension],
    )
    active_span_mock.span.set_tag.assert_called_once_with(tags.COMPONENT, "graphql") 
开发者ID:mirumee,项目名称:ariadne,代码行数:11,代码来源:test_opentracing_sync.py

示例6: test_opentracing_extension_sets_graphql_component_tag_on_root_span

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def test_opentracing_extension_sets_graphql_component_tag_on_root_span(
    schema, active_span_mock
):
    await graphql(
        schema,
        {"query": '{ status hello(name: "Bob") }'},
        extensions=[OpenTracingExtension],
    )
    active_span_mock.span.set_tag.assert_called_once_with(tags.COMPONENT, "graphql") 
开发者ID:mirumee,项目名称:ariadne,代码行数:11,代码来源:test_opentracing.py

示例7: request_started

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def request_started(self, context: ContextValue):
        self._root_scope = self._tracer.start_active_span("GraphQL Query")
        self._root_scope.span.set_tag(tags.COMPONENT, "graphql") 
开发者ID:mirumee,项目名称:ariadne,代码行数:5,代码来源:opentracing.py

示例8: _before_request_fn

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def _before_request_fn(self, attributes):
        request = stack.top.request
        operation_name = request.endpoint
        headers = {}
        for k, v in request.headers:
            headers[k.lower()] = v

        try:
            span_ctx = self.tracer.extract(opentracing.Format.HTTP_HEADERS,
                                           headers)
            scope = self.tracer.start_active_span(operation_name,
                                                  child_of=span_ctx)
        except (opentracing.InvalidCarrierException,
                opentracing.SpanContextCorruptedException):
            scope = self.tracer.start_active_span(operation_name)

        self._current_scopes[request] = scope

        span = scope.span
        span.set_tag(tags.COMPONENT, 'Flask')
        span.set_tag(tags.HTTP_METHOD, request.method)
        span.set_tag(tags.HTTP_URL, request.base_url)
        span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_SERVER)

        for attr in attributes:
            if hasattr(request, attr):
                payload = getattr(request, attr)
                if payload not in ('', b''):  # python3
                    span.set_tag(attr, str(payload))

        self._call_start_span_cb(span, request) 
开发者ID:opentracing-contrib,项目名称:python-flask,代码行数:33,代码来源:tracing.py

示例9: test_span_tags

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def test_span_tags(self):
        test_app.get('/another_test_simple')

        spans = tracing._tracer.finished_spans()
        assert len(spans) == 1
        assert spans[0].tags == {
            tags.COMPONENT: 'Flask',
            tags.HTTP_METHOD: 'GET',
            tags.SPAN_KIND: tags.SPAN_KIND_RPC_SERVER,
            tags.HTTP_URL: 'http://localhost/another_test_simple',
            'is_xhr': 'False',
        } 
开发者ID:opentracing-contrib,项目名称:python-flask,代码行数:14,代码来源:test_flask_tracing.py

示例10: test_simple

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def test_simple(self):
        def start_span_cb(span, request):
            span.set_tag('component', 'not-flask')
            span.set_tag('mytag', 'myvalue')

        tracing = FlaskTracing(MockTracer(), True, app,
                               start_span_cb=start_span_cb)
        rv = test_app.get('/test')
        assert '200' in str(rv.status_code)

        spans = tracing.tracer.finished_spans()
        assert len(spans) == 1
        assert spans[0].tags.get(tags.COMPONENT, None) == 'not-flask'
        assert spans[0].tags.get('mytag', None) == 'myvalue' 
开发者ID:opentracing-contrib,项目名称:python-flask,代码行数:16,代码来源:test_flask_tracing.py

示例11: _start_span

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def _start_span(self, method):
        active_span_context = None
        if self._active_span_source is not None:
            active_span = self._active_span_source.get_active_span()
            if active_span is not None:
                active_span_context = active_span.context
        tags = {
            ot_tags.COMPONENT: 'grpc',
            ot_tags.SPAN_KIND: ot_tags.SPAN_KIND_RPC_CLIENT
        }
        return self._tracer.start_span(
            operation_name=method, child_of=active_span_context, tags=tags) 
开发者ID:opentracing-contrib,项目名称:python-grpc,代码行数:14,代码来源:_client.py

示例12: set_common_tags

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def set_common_tags(span, task, span_kind):
    span.set_tag(tags.SPAN_KIND, span_kind)
    span.set_tag(tags.COMPONENT, 'Celery')
    span.set_tag('celery.task_name', task.name) 
开发者ID:uber-common,项目名称:opentracing-python-instrumentation,代码行数:6,代码来源:celery.py

示例13: assert_span

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def assert_span(span, result, operation, span_kind):
    assert span.operation_name == 'Celery:{}:foo'.format(operation)
    assert span.tags.get(tags.SPAN_KIND) == span_kind
    assert span.tags.get(tags.COMPONENT) == 'Celery'
    assert span.tags.get('celery.task_name') == 'foo'
    assert span.tags.get('celery.task_id') == result.task_id 
开发者ID:uber-common,项目名称:opentracing-python-instrumentation,代码行数:8,代码来源:test_celery.py

示例14: assert_last_span

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def assert_last_span(kind, service_name, operation, tracer, response=None):
    span = tracer.recorder.get_spans()[-1]
    request_id = response and response['ResponseMetadata'].get('RequestId')
    assert span.operation_name == 'boto3:{}:{}:{}'.format(
        kind, service_name, operation
    )
    assert span.tags.get(tags.SPAN_KIND) == tags.SPAN_KIND_RPC_CLIENT
    assert span.tags.get(tags.COMPONENT) == 'boto3'
    assert span.tags.get('boto3.service_name') == service_name
    if request_id:
        assert span.tags.get('aws.request_id') == request_id 
开发者ID:uber-common,项目名称:opentracing-python-instrumentation,代码行数:13,代码来源:test_boto3.py

示例15: assert_span

# 需要导入模块: from opentracing.ext import tags [as 别名]
# 或者: from opentracing.ext.tags import COMPONENT [as 别名]
def assert_span(span, operation):
    assert span.operation_name == 'SQL ' + operation
    assert span.tags.get(tags.SPAN_KIND) == tags.SPAN_KIND_RPC_CLIENT
    assert span.tags.get(tags.DATABASE_TYPE) == 'sqlite'
    assert span.tags.get(tags.DATABASE_INSTANCE) == 'sqlite://'
    assert span.tags.get(tags.COMPONENT) == 'sqlalchemy' 
开发者ID:uber-common,项目名称:opentracing-python-instrumentation,代码行数:8,代码来源:test_sqlalchemy.py


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