motan学习笔记 五 opentracing学习入门
2017-01-02 10:34
225 查看
motan学习笔记 二 motan架构分析
motan学习笔记 三 motan Demo 分析
motan学习笔记 四 motan Demo 之yar 分析
motan学习笔记 五 opentracing学习入门
motan学习笔记 六 opentracing Brave+zipkin实现
opentracing是什么?
opentracing(http://opentracing.io/) 是分布式跟踪系统,当我们把系统拆成服务化,分布式系统的时候,查询一个问题,很可能需要多个登录多台机器。opentracing 定义了一套api
通过提供平台无关、厂商无关的API,使得开发人员能够方便的添加(或更换)追踪系统的实现。OpenTracing正在为全球的分布式追踪,提供统一的概念和数据标准。
opentracing 在哪里有java版?
从github,下载java版本的分支(https://github.com/opentracing/opentracing-java)从下面的图,可以看出api为定义模块,mock挡板 noop空实现 impl具体实现
opentracing 定义了哪些api?
span
一条消息,相当于一个打点信息,里面有两个重要的方法 finish 和 其他finish 用来完成span的信息,并且用于提交 而其他方法用来组装span的数据
SpanContext
及传输的上下文,保存一些数据,一般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 { /** * A shorthand for addReference(References.CHILD_OF, parent). */ SpanBuilder asChildOf(SpanContext parent); /** * A shorthand for addReference(References.CHILD_OF, parent.context()). */ SpanBuilder asChildOf(Span parent); /** * Add a reference from the Span being built to a distinct (usually parent) Span. May be called multiple times to * represent multiple such References. * * @param referenceType the reference type, typically one of the constants defined in References * @param referencedContext the SpanContext being referenced; e.g., for a References.CHILD_OF referenceType, the * referencedContext is the parent * * @see io.opentracing.References */ SpanBuilder addReference(String referenceType, SpanContext referencedContext); /** Same as {@link Span#setTag(String, String)}, but for the span being built. */ SpanBuilder withTag(String key, String value); /** Same as {@link Span#setTag(String, String)}, but for the span being built. */ SpanBuilder withTag(String key, boolean value); /** Same as {@link Span#setTag(String, String)}, but for the span being built. */ SpanBuilder withTag(String key, Number value); /** Specify a timestamp of when the Span was started, represented in microseconds since epoch. */ SpanBuilder withStartTimestamp(long microseconds); /** Returns the started Span. */ Span start(); }
相关文章推荐
- C#学习笔记(一)-- 入门的困惑
- jni入门学习笔记(一)
- webservice学习笔记——入门篇
- 李浩学习计算机系列笔记——ADO.NET基础入门
- Spring学习笔记:2-Spring中IoC的入门实例
- Struts入门文章系列(链接)及学习笔记
- XML学习笔记,快速入门
- CSS入门学习笔记[1]
- windows 2003从入门到精通学习笔记
- jni入门学习笔记(一)
- Lua入门系列----pil学习笔记之Type and Values (2)
- c++入门学习笔记指针篇
- Javascript教程,javascript入门,学习笔记,Javascript Tutorials
- Javascript:Javascript教程,javascript入门,学习笔记
- XML学习笔记之入门
- Lua入门系列----pil学习笔记之 Type and Values (1)
- 计算机图形学入门Gossip学习笔记
- SP.NET 2.0入门经典学习笔记2.txt
- “ASP.Net快速入门”学习笔记
- webservice学习笔记——入门篇