Opentracing 是分布式链路追踪的一种规范标准 (现在改名为OpenTelemetry),发布于 2016 年 12 月,是 CNCF(云原生计算基金会)下的项目之一。和一般的规范标准不同,Opentracing 不是传输协议,消息格式层面上的规范标准,而是一种语言层面上的 API 标准。以 Go 语言为例,只要某链路追踪系统实现了 Opentracing 规定的接口(interface),符合 Opentracing 定义的表现行为,那么就可以说该应用符合 Opentracing 标准。这意味着开发者只需修改少量的配置代码,就可以在符合 Opentracing 标准的链路追踪系统之间自由切换。
Table of Contents
标准文档
https://opentracing.io/specification/
语言无关 proto 定义
https://github.com/open-telemetry/opentelemetry-proto
概念
一个 tracer 过程中,各 span 的关系:
[Span A] ←←←(the root span)
|
+------+------+
| |
[Span B] [Span C] ←←←(Span C 是 Span A 的孩子节点, ChildOf)
| |
[Span D] +---+-------+
| |
[Span E] [Span F] >>> [Span G] >>> [Span H]
↑
↑
↑
(Span G 在 Span F 后被调用, FollowsFrom)
上述 tracer 与 span 的时间轴关系:
––|–––––––|–––––––|–––––––|–––––––|–––––––|–––––––|–––––––|–> time
[Span A···················································]
[Span B··············································]
[Span D··········································]
[Span C········································]
[Span E·······] [Span F··] [Span G··] [Span H··]
规范
Opentracing json message 格式,不拘用什么客户端,只要符合这种格式的消息就可以复用 Opentracing 工具链。
{
"trace_id": undefined, // values for trace_id and span_id are not currently standardized
"span_id": undefined,
"references": [
{"type":"child_of","span_id":undefined}, // currently types are "child_of" and "follows_from"
],
"name": "operation type",
"timestamp": 1234567890123456789, // UTC Epoch Unix Timestamp in Microseconds
"duration": 300, // integer representing microseconds
"tags": {
"tag_key": [{"a":"b"},{"c":"d"}], // can tags have multiple values in some systems?
},
"logs": [
{"timestamp":1234567890123456789, "a":"b"}, // logs optionally have a timestamp
],
"baggage": {"a":"b"},
}
数据收集
数据收集由 3 个组件构成:
- receivers: How to get data into the Collector; these can be push or pull based
- processors: What to do with received data
- exporters: Where to send received data; these can be push or pull based
https://github.com/open-telemetry/opentelemetry-collector
opentelemetry-collector 示例
https://www.aspecto.io/blog/opentelemetry-collector-guide/
opentelemetry-collector receiver 列表
https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver
HTTP Transport Extension for OTLP
This is a proposal to add HTTP Transport extension for OTLP (OpenTelemetry Protocol).
https://github.com/open-telemetry/oteps/blob/main/text/0099-otlp-http.md#request
Tracing 相关方案
Uptrace
Jaeger
Sentry
SkyWalking
SigNoz
Zipkin
Grafana Tempo
DataDog
有不少 tracing 工具底层应该是兼容 OpenTracing 协议的。
Sample go app
https://github.com/SigNoz/sample-golang-app
Reference
Standard Interchange Format for OpenTracing
distributed-tracing-tools
Instrumenting a Go application with OpenTelemetry
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Your article helped me a lot, is there any more related content? Thanks!
In ffact noo mater iif someone doesn’t knkw afterward its uup tto other pople that they will help, so her itt occurs.
Loook iinto myy web blog; freepornmovies.biz
Incredible! This bloog looks eactly likie my oldd one!
It’s oon a entirely different topc butt iit hass prettty mudh
thhe sake laytout and design. Outstanding cnoice off
colors!
My blog post: how do you like that obama i pissed on the moon