我是 zipkin 和勇敢的 api 分发跟踪的新手。我已经在我的 localhost 上设置了一个 zipkin 服务器,监听端口 9411。我已经执行了下面的函数,但我的 zipkin 服务器中没有显示跟踪数据。有人能指出我错过了什么吗?
public static void main(String[] args) {
Sender sender = OkHttpSender.create("http://localhost:9411/api/v1/spans");
Reporter reporter = AsyncReporter.builder(sender).build();
// Now, create a tracer with the service name you want to see in Zipkin.
Tracer tracer = Tracer.newBuilder()
.localServiceName("my-service")
.reporter(reporter)
.build();
Span twoPhase = tracer.newTrace().name("twoPhase").start();
try {
Span prepare = tracer.newChild(twoPhase.context()).name("prepare").start();
try {
System.out.print("prepare");
} finally {
prepare.finish();
}
Span commit = tracer.newChild(twoPhase.context()).name("commit").start();
try {
System.out.print("commit");
} finally {
commit.finish();
}
} finally {
twoPhase.finish();
}
}