jaeger问题
来源:47-1 python发送单个span

南森_
2021-10-11
import requests
import logging
import time
from random import randint
from jaeger_client import Config
if __name__ == "__main__":
log_level = logging.DEBUG
logging.getLogger('').handlers = []
logging.basicConfig(format='%(asctime)s %(message)s', level=log_level)
config = Config(
config={
# usually read from some yaml config
'sampler': {
'type': 'const', #全部
'param': 1, #1 开启全部采样 0 表示关闭全部采样
},
# jaeger所在服务器
'local_agent': {
'reporting_host': '116.62.145.195',
'reporting_port': '6831',
},
'logging': True,
},
service_name="mxshop",
validate=True,
)
# this call also sets opentracing.tracer
tracer = config.initialize_tracer()
with tracer.start_span("get") as spider_span:
with tracer.start_span("get", child_of=spider_span) as get_span:
requests.get("https://www.baidu.com")
with tracer.start_span("parser", child_of=spider_span) as parser_span:
time.sleep(randint(1,9)*0.1)
time.sleep(2) # yield to IOLoop to flush the spans - https://github.com/jaegertracing/jaeger-client-python/issues/50
tracer.close() # flush any buffered spans
不知道为什么运行后,服务名都不对,多个span也不对?
我的环境
阿里云ubuntu18.4,
python3.7和3.6都试过情况都一样
我猜是不是python版本问题呢?
写回答
1回答
-
南森_
提问者
2021-10-11
解决了
jaeger的公网IP改成私网IP
我猜测原因就是,jaeger所在服务器,我写成公网的了,调用的使用出现了问题,因为我在阿里云用了两个服务器,用的一个专有网络,他们之间的调用就出了问题。改成私网ip调用就可以了
012021-10-11
相似问题