opentracing是什么?
opentracing 定义了一套api
通过提供平台无关、厂商无关的API,使得开发人员能够方便的添加(或更换)追踪系统的实现。OpenTracing正在为全球的分布式追踪,提供统一的概念和数据标准。
opentracing 在哪里有java版?
从下面的图,可以看出api为定义模块,mock挡板 noop空实现 impl具体实现
opentracing 定义了哪些api?
span
一条消息,相当于一个打点信息,里面有两个重要的方法
finish 和 其他
finish 用来完成span的信息,并且用于提交 而其他方法用来组装span的数据
及传输的上下文,保存一些数据,一般loaclThread的,主要方法
Iterable<Map.Entry<String, String>> baggageItems();
Tracer
定义了两个方法,一个是往spancontext 插入参数,一个获取spancontext,相当于span集合
- <C> void inject(SpanContext spanContext, Format<C> format, C carrier);
- <C> SpanContext extract(Format<C> format, C carrier);
Format其实就是 定义的几个map
- public interface Format<C> {
- final class Builtin<C> implements Format<C> {
- public final static Format<TextMap> TEXT_MAP = new Builtin<TextMap>();
- public final static Format<TextMap> HTTP_HEADERS = new Builtin<TextMap>();
- public final static Format<ByteBuffer> BINARY = new Builtin<ByteBuffer>();
- }
SpanBuilder
顾名思义,builder模式,用来构建 span, 关键是start方法,构建成功
- interface SpanBuilder extends SpanContext {
-
-
-
-
- SpanBuilder asChildOf(SpanContext parent);
-
-
-
-
- SpanBuilder asChildOf(Span parent);
-
-
-
-
-
-
-
-
-
-
-
- SpanBuilder addReference(String referenceType, SpanContext referencedContext);
-
-
- SpanBuilder withTag(String key, String value);
-
-
- SpanBuilder withTag(String key, boolean value);
-
-
- SpanBuilder withTag(String key, Number value);
-
-
- SpanBuilder withStartTimestamp(long microseconds);
-
-
- Span start();
-
- }