如何从OpenTracing API获取跟踪ID? [英] How can I get a trace ID from OpenTracing API?

查看:493
本文介绍了如何从OpenTracing API获取跟踪ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#105 davidB问:

我希望对Span ID(SpanContext ID)具有读取访问权限,以便能够在日志中使用它并以错误的方式报告给(最终用户,...). [跳过]我需要在错误消息中公开跟踪ID",然后开发人员可以使用跟踪来调试由支持人员,质量检查人员和最终用户报告的错误.

I would like to have read access to the Span id (SpanContext id) to be able to use it in log and in error reported (to end user,...). [skip] I need to expose the "trace id" in error message, then dev could use the trace to debug error reported by support, QA, end-user.

推荐答案

您现在可以做的一件事是调用tracer.inject(null, Builtin.HTTP_HEADERS, map.它将所有带有行李(SpanContext)的ID放入地图中.然后,您可以通过其名称获取ID.但是,该解决方案不是韦德尔中立的.

One thing you can do right now is to call tracer.inject(null, Builtin.HTTP_HEADERS, map. It will put all IDs with baggage (SpanContext) into the map. Then you can get ID by its name. However this solution is not vedor neutral.

其他解决方案是将SpanContext转换为特定的实现,并通过getter获取ID(如果有)

Other solution is to cast SpanContext into specific implementation and get the IDs by getter (if there is any)

这篇关于如何从OpenTracing API获取跟踪ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆