博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
motan学习笔记 五 opentracing学习入门
阅读量:2176 次
发布时间:2019-05-01

本文共 2706 字,大约阅读时间需要 9 分钟。

opentracing是什么?

opentracing()  是分布式跟踪系统,当我们把系统拆成服务化,分布式系统的时候,查询一个问题,很可能需要多个登录多台机器。
opentracing 定义了一套api
通过提供平台无关、厂商无关的API,使得开发人员能够方便的添加(或更换)追踪系统的实现。OpenTracing正在为全球的分布式追踪,提供统一的概念和数据标准。

opentracing 在哪里有java版?

从github,下载java版本的分支( )
从下面的图,可以看出api为定义模块,mock挡板 noop空实现  impl具体实现

opentracing 定义了哪些api?

span

一条消息,相当于一个打点信息,里面有两个重要的方法  
finish 和 其他
finish 用来完成span的信息,并且用于提交 而其他方法用来组装span的数据

SpanContext

及传输的上下文,保存一些数据,一般loaclThread的,主要方法

Iterable<Map.Entry<String, String>> baggageItems();

Tracer

定义了两个方法,一个是往spancontext 插入参数,一个获取spancontext,相当于span集合

void inject(SpanContext spanContext, Format
format, C carrier);
SpanContext extract(Format
format, C carrier);

Format其实就是 定义的几个map  
public interface Format
{ final class Builtin
implements Format
{ public final static Format
TEXT_MAP = new Builtin
(); public final static Format
HTTP_HEADERS = new Builtin
(); public final static Format
BINARY = new Builtin
(); }

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();  }
你可能感兴趣的文章
【雅思】雅思写作作业(1)
查看>>
【雅思】【大作文】【审题作业】关于同不同意的审题作业(重点)
查看>>
【Loadrunner】通过loadrunner录制时候有事件但是白页无法出来登录页怎么办?
查看>>
【English】【托业】【四六级】写译高频词汇
查看>>
【托业】【新东方全真模拟】01~02-----P5~6
查看>>
【托业】【新东方全真模拟】03~04-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST05~06-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST09~10-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST07~08-----P5~6
查看>>
solver及其配置
查看>>
JAVA多线程之volatile 与 synchronized 的比较
查看>>
Java集合框架知识梳理
查看>>
笔试题(一)—— java基础
查看>>
Redis学习笔记(三)—— 使用redis客户端连接windows和linux下的redis并解决无法连接redis的问题
查看>>
Intellij IDEA使用(一)—— 安装Intellij IDEA(ideaIU-2017.2.3)并完成Intellij IDEA的简单配置
查看>>
Intellij IDEA使用(二)—— 在Intellij IDEA中配置JDK(SDK)
查看>>
Intellij IDEA使用(三)——在Intellij IDEA中配置Tomcat服务器
查看>>
Intellij IDEA使用(四)—— 使用Intellij IDEA创建静态的web(HTML)项目
查看>>
Intellij IDEA使用(五)—— Intellij IDEA在使用中的一些其他常用功能或常用配置收集
查看>>
Intellij IDEA使用(六)—— 使用Intellij IDEA创建Java项目并配置jar包
查看>>