问题描述
我是 opencensus 的新手,我正在尝试这个 quick-start-example 我想将跟踪导出到 zipkin 因为我添加了导出器代码并且 zipkin 在 docker 上运行
跟踪没有导出到 zipkin 这里是我的示例代码
object ExporterExample {
private val tracer = Tracing.getTracer
val log = LoggerFactory.getLogger(this.getClass)
def doWork()= {
try {
val ss:Scope =
tracer
.spanBuilder("MyChildWorkSpan")
.setRecordEvents(true)
.setSampler(Samplers.probabilitySampler(1.0))
.setSampler(Samplers.alwaysSample())
.startScopedSpan()
doInitialWork
tracer.getCurrentSpan.addAnnotation("Finished initial work")
doFinalWork
log.info("tracer id is {}",tracer.getCurrentSpan.getContext.getTraceId)
}
catch {
case e :Exception=>
tracer.getCurrentSpan.addAnnotation("Exception thrown when processing video.")
tracer.getCurrentSpan.setStatus(Status.UNKNOWN)
}
}
def doInitialWork={
tracer.getCurrentSpan.addAnnotation("Important.")
}
def doFinalWork={
tracer.getCurrentSpan.addAnnotation("More important.")
}
def main(args: Array[String]): Unit = {
ZipkinTraceExporter.createAndRegister(ZipkinExporterConfiguration.builder().setServiceName("quick-start").setV2Url("http://0.0.0.0:9411/api/v2/spans").build())
doWork()
}
}
我也尝试通过跟踪 ID 进行搜索,但没有显示
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)