【发布时间】:2021-10-25 21:49:29
【问题描述】:
出于测试目的,我正在尝试在localhost 中接收 Jaeger 报告,并检查某些值是否符合要求。我这样设置 Jaeger:
def setup_env(tracing_enabled, tracing_port):
os.environ['JAEGER_DISABLED'] = 'false'
os.environ['JAEGER_REPORTER_FLUSH_INTERVAL'] = '1ms'
os.environ['JAEGER_AGENT_HOST'] = 'localhost'
os.environ['JAEGER_AGENT_PORT'] = f'{tracing_port}'
os.environ['JAEGER_SAMPLER_TYPE'] = 'const'
os.environ['JAEGER_SAMPLER_PARAM'] = '1'
os.environ['JAEGER_REPORTER_LOG_SPANS'] = 'true'
tracing_port 是我在localhost 中打开的套接字的端口,如下所示:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('127.0.0.1', 0))
sock.setblocking(0)
在我的测试中,我是
def test_jaeger():
// start the service ...
all_data = bytearray()
data = bytes()
try:
data, _ = udp_socket.recvfrom(1024)
except BlockingIOError:
pass
while data:
all_data.extend(data)
try:
data, _ = udp_socket.recvfrom(1024)
except BlockingIOError:
data = None
print(all_data)
这一切都像一个魅力。我在套接字中得到了 something,我将其视为
bytearray(b'\x82\x81\x01\temitBatch\x1c\x1c\x18\x0becho_server\x19<\x18\x0ejaeger.version\x15\x00\x18\x0cPython-4.8.0\x00\x18\x02ip\x15\x00\x18\r172.16.20.205\x00\x18\x08hostname\x15\x00\x18\x1cGuillermos-MacBook-Pro.local\x00\x00\x19\x1c\x16\xe6\xc2\x84\x96\xe7\xd4\xf2\x88\x04\x16\x00\x16\x8b\xeb\xa6\xb0\x81\x99\xec\xfc\xe3\x01\x16\x00\x18\x03GET%\x02\x16\xe6\xca\xfb\xe4\x88\xcd\xe7\x05\x16\xfc\x17\x19l\x18\x0csampler.type\x15\x00\x18\x05const\x00\x18\rsampler.param\x15\x041\x00\x18\tspan.kind\x15\x00\x18\x06server\x00\x18\x08http.url\x15\x00\x18\x1dhttp://127.0.0.1:54298/health\x00\x18\x0bhttp.method\x15\x00\x18\x03GET\x00\x18\tpeer.ipv4\x15\x00\x18\t127.0.0.1\x00\x19\x0c\x00\x00\x00')
现在我需要将其反序列化为我可以正确检查的内容。我尝试了各种各样的东西,都没有奏效。有人知道怎么做吗?
【问题讨论】:
标签: python encoding deserialization jaeger opentracing