本文整理汇总了Python中opentracing.Format.BINARY属性的典型用法代码示例。如果您正苦于以下问题:Python Format.BINARY属性的具体用法?Python Format.BINARY怎么用?Python Format.BINARY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类opentracing.Format
的用法示例。
在下文中一共展示了Format.BINARY属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_inject
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [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 == {}
示例2: _register_required_propagators
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [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())
示例3: test_binary_propagation
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [as 别名]
def test_binary_propagation(self):
with self.tracer().start_span(operation_name='Bender') as span:
bin_carrier = bytearray()
self.tracer().inject(
span_context=span.context,
format=opentracing.Format.BINARY,
carrier=bin_carrier)
extracted_ctx = self.tracer().extract(
format=opentracing.Format.BINARY,
carrier=bin_carrier)
assert extracted_ctx.baggage == {}
示例4: test_mandatory_formats
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [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)
示例5: test_extract
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [as 别名]
def test_extract():
tracer = Tracer()
noop_span = tracer._noop_span
bin_carrier = bytearray()
span_ctx = tracer.extract(Format.BINARY, carrier=bin_carrier)
assert noop_span.context == span_ctx
text_carrier = {}
span_ctx = tracer.extract(Format.TEXT_MAP, carrier=text_carrier)
assert noop_span.context == span_ctx
示例6: __init__
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [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())
示例7: register_required_propagators
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [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())
示例8: test_tracer_extract_binary
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [as 别名]
def test_tracer_extract_binary(tracer):
with pytest.raises(opentracing.UnsupportedFormatException):
tracer.extract(Format.BINARY, b"foo")
示例9: test_tracer_inject_binary
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [as 别名]
def test_tracer_inject_binary(tracer):
span_context = OTSpanContext(
trace_parent=TraceParent.from_string("00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01")
)
with pytest.raises(opentracing.UnsupportedFormatException):
tracer.inject(span_context, Format.BINARY, {})
示例10: test_tracer_override_codecs
# 需要导入模块: from opentracing import Format [as 别名]
# 或者: from opentracing.Format import BINARY [as 别名]
def test_tracer_override_codecs():
reporter = mock.MagicMock()
sampler = ConstSampler(True)
codecs = {
'extra_codec': 'codec_placeholder',
Format.BINARY: 'overridden_binary_codec'
}
with mock.patch('socket.gethostname', return_value='dream-host.com'):
tracer = Tracer(service_name='x', reporter=reporter, sampler=sampler,
extra_codecs=codecs)
assert tracer.codecs['extra_codec'] == 'codec_placeholder',\
'Extra codec not found'
assert tracer.codecs[Format.BINARY] == 'overridden_binary_codec',\
'Binary format codec not overridden'