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


Python Format.TEXT_MAP属性代码示例

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


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

示例1: test_inject

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def test_inject():
    tracer = Tracer()
    span = tracer.start_span()

    bin_carrier = bytearray()
    tracer.inject(
        span_context=span.context,
        format=Format.BINARY,
        carrier=bin_carrier)
    assert bin_carrier == bytearray()

    text_carrier = {}
    tracer.inject(
        span_context=span.context,
        format=Format.TEXT_MAP,
        carrier=text_carrier)
    assert text_carrier == {} 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:19,代码来源:test_noop_span.py

示例2: receive

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def receive(self, envelope: MessageEnvelope) -> None:
        message = envelope.message
        parent_span_ctx = None
        if envelope.header is not None:
            parent_span_ctx = self._tracer.extract(format=Format.TEXT_MAP, carrier=envelope.header)

        with OpenTracingHelper.build_started_scope(self._tracer, parent_span_ctx, 'receive', message,
                                                   self._receive_span_setup) as scope:
            try:
                if envelope.sender is not None:
                    scope.span.set_tag('proto.senderpid', envelope.sender.to_short_string())
                if self._receive_span_setup is not None:
                    self._receive_span_setup(scope.span, message)
                await super().receive(envelope)
            except Exception as ex:
                OpenTracingHelper.setup_span(ex, scope.span)
                raise Exception() 
开发者ID:AsynkronIT,项目名称:protoactor-python,代码行数:19,代码来源:open_tracing_decorator.py

示例3: open_tracing_sender_middleware

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def open_tracing_sender_middleware(tracer: Tracer = None):
    def level_0(next):
        async def level_1(context: AbstractSenderContext, target: PID, envelope: MessageEnvelope):
            if tracer is None:
                inner_tracer = opentracing.global_tracer()
            else:
                inner_tracer = tracer
            span = inner_tracer.active_span
            if span is None:
                await next(context, target, envelope)
            else:
                dictionary = {}
                inner_tracer.inject(span.context, Format.TEXT_MAP, dictionary)
                envelope = envelope.with_headers(dictionary)
                await next(context, target, envelope)

        return level_1

    return level_0 
开发者ID:AsynkronIT,项目名称:protoactor-python,代码行数:21,代码来源:open_tracing_middleware.py

示例4: test_new_trace

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def test_new_trace():
    tracer = Tracer()

    span = tracer.start_span(operation_name='test')
    span.set_baggage_item('Fry', 'Leela')
    span.set_tag('x', 'y')
    span.log_event('z')

    child = tracer.start_span(operation_name='child',
                              references=opentracing.child_of(span.context))
    child.log_event('w')
    assert child.get_baggage_item('Fry') is None
    carrier = {}
    tracer.inject(
        span_context=child.context,
        format=Format.TEXT_MAP,
        carrier=carrier)
    assert carrier == dict()
    child.finish()

    span.finish() 
开发者ID:jaegertracing,项目名称:jaeger-client-python,代码行数:23,代码来源:test_noop_tracer.py

示例5: test_join_trace

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def test_join_trace():
    tracer = Tracer()

    span_ctx = tracer.extract(format=Format.TEXT_MAP, carrier={})
    span = tracer.start_span(operation_name='test',
                             references=opentracing.child_of(span_ctx))
    span.set_tag('x', 'y')
    span.set_baggage_item('a', 'b')
    span.log_event('z')

    child = tracer.start_span(operation_name='child',
                              references=opentracing.child_of(span.context))
    child.log_event('w')
    child.finish()

    span.finish() 
开发者ID:jaegertracing,项目名称:jaeger-client-python,代码行数:18,代码来源:test_noop_tracer.py

示例6: test_serialization

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def test_serialization(tracer, inject_mode):
    span = tracer.start_span('help')
    carrier = {}
    if inject_mode == 'span':
        injectable = span
    elif inject_mode == 'context':
        injectable = span.context
    else:
        raise ValueError('bad inject_mode')
    tracer.inject(
        span_context=injectable, format=Format.TEXT_MAP, carrier=carrier
    )
    assert len(carrier) > 0
    h_ctx = tornado.httputil.HTTPHeaders(carrier)
    assert 'UBER-TRACE-ID' in h_ctx
    ctx2 = tracer.extract(Format.TEXT_MAP, carrier)
    assert ctx2 is not None
    assert ctx2.trace_id == span.trace_id
    assert ctx2.span_id == span.span_id
    assert ctx2.parent_id == span.parent_id
    assert ctx2.flags == span.flags 
开发者ID:jaegertracing,项目名称:jaeger-client-python,代码行数:23,代码来源:test_tracer.py

示例7: test_debug_id

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def test_debug_id():
    debug_header = 'correlation-id'
    tracer = Tracer(
        service_name='test',
        reporter=InMemoryReporter(),
        sampler=ConstSampler(True),
        debug_id_header=debug_header,
    )
    tracer.codecs[Format.TEXT_MAP] = TextCodec(
        url_encoding=False,
        debug_id_header=debug_header,
    )
    carrier = {debug_header: 'Coraline'}
    context = tracer.extract(Format.TEXT_MAP, carrier)
    assert context.is_debug_id_container_only
    assert context.debug_id == 'Coraline'
    span = tracer.start_span('test', child_of=context)
    assert span.is_debug()
    assert span.is_sampled()
    tags = [t for t in span.tags if t.key == debug_header]
    assert len(tags) == 1
    assert tags[0].vStr == 'Coraline' 
开发者ID:jaegertracing,项目名称:jaeger-client-python,代码行数:24,代码来源:test_codecs.py

示例8: _get_span

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def _get_span(self):
        try:
            carrier = {}
            for k, v in six.iteritems(self.request.headers):
                carrier[k] = six.moves.urllib.parse.unquote(v)
            span_ctx = opentracing.tracer.extract(Format.TEXT_MAP, carrier)
            span = opentracing.tracer.start_span(
                operation_name='server',
                child_of=span_ctx,
            )
        except Exception as e:
            self.write('ERROR: %s' % e)
            self.set_status(200)
            return None

        if span is None:
            self.write('ERROR: Failed to join trace')
            self.set_status(200)

        return span 
开发者ID:uber,项目名称:tchannel-python,代码行数:22,代码来源:test_tracing.py

示例9: register_propagator

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def register_propagator(self, format, propagator):
        """Register a propagator with this MockTracer.

        :param string format: a :class:`~opentracing.Format`
            identifier like :attr:`~opentracing.Format.TEXT_MAP`
        :param **Propagator** propagator: a **Propagator** instance to handle
            inject/extract calls involving `format`
        """
        self._propagators[format] = propagator 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:11,代码来源:tracer.py

示例10: _register_required_propagators

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def _register_required_propagators(self):
        from .text_propagator import TextPropagator
        from .binary_propagator import BinaryPropagator
        self.register_propagator(Format.TEXT_MAP, TextPropagator())
        self.register_propagator(Format.HTTP_HEADERS, TextPropagator())
        self.register_propagator(Format.BINARY, BinaryPropagator()) 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:8,代码来源:tracer.py

示例11: test_text_propagation

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def test_text_propagation(self):
        with self.tracer().start_span(operation_name='Bender') as span:
            text_carrier = {}
            self.tracer().inject(
                span_context=span.context,
                format=opentracing.Format.TEXT_MAP,
                carrier=text_carrier)
            extracted_ctx = self.tracer().extract(
                format=opentracing.Format.TEXT_MAP,
                carrier=text_carrier)
            assert extracted_ctx.baggage == {} 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:13,代码来源:api_check.py

示例12: test_mandatory_formats

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def test_mandatory_formats(self):
        formats = [
            (Format.TEXT_MAP, {}),
            (Format.HTTP_HEADERS, {}),
            (Format.BINARY, bytearray()),
        ]
        with self.tracer().start_span(operation_name='Bender') as span:
            for fmt, carrier in formats:
                # expecting no exceptions
                span.tracer.inject(span.context, fmt, carrier)
                span.tracer.extract(fmt, carrier) 
开发者ID:opentracing,项目名称:opentracing-python,代码行数:13,代码来源:api_check.py

示例13: __init__

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def __init__(self, enable_binary_format, recorder, scope_manager):
        """Initialize the LightStep Tracer, deferring to BasicTracer."""
        super(_LightstepTracer, self).__init__(recorder, scope_manager=scope_manager)
        self.register_propagator(Format.TEXT_MAP, TextPropagator())
        self.register_propagator(Format.HTTP_HEADERS, TextPropagator())
        if enable_binary_format:
            # We do this import lazily because protobuf versioning issues
            # can cause process-level failure at import time.
            from basictracer.binary_propagator import BinaryPropagator
            self.register_propagator(Format.BINARY, BinaryPropagator())
            self.register_propagator(LightStepFormat.LIGHTSTEP_BINARY, LightStepBinaryPropagator()) 
开发者ID:lightstep,项目名称:lightstep-tracer-python,代码行数:13,代码来源:tracer.py

示例14: register_propagator

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def register_propagator(self, format, propagator):
        """Register a propagator with this BasicTracer.

        :param string format: a Format identifier like Format.TEXT_MAP
        :param Propagator propagator: a Propagator instance to handle
            inject/extract calls involving `format`
        """
        self._propagators[format] = propagator 
开发者ID:opentracing,项目名称:basictracer-python,代码行数:10,代码来源:tracer.py

示例15: register_required_propagators

# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import TEXT_MAP [as 别名]
def register_required_propagators(self):
        from .text_propagator import TextPropagator
        from .binary_propagator import BinaryPropagator
        self.register_propagator(Format.TEXT_MAP, TextPropagator())
        self.register_propagator(Format.HTTP_HEADERS, TextPropagator())
        self.register_propagator(Format.BINARY, BinaryPropagator()) 
开发者ID:opentracing,项目名称:basictracer-python,代码行数:8,代码来源:tracer.py


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