Go Tracing Roadmap

Go Tracing Roadmap golang 分布式追踪的路演,今后可能直接从语言层面支持这些特性,golang真是太棒了,原始文档在 google doc 上,可能有些同学网络不太方面,所以转一份在这里

Jaana B. Dogan (jbd@golang.org),May 15,2017

This document summarizes the state of the distributed tracing related work for the Go ecosystem. It is recommended to read the Dapper (google 2010年发表的一个关于分布式追踪系统架构的论文) paper before reading this document to understand the higher level concepts and terminology in distributed tracing.

Dapper,a Large-Scale Distributed Systems Tracing Infrastructure

Background

Go ecosystem provides a large set of solutions for distributed tracing such as x/net/trace,OpenTracing,tracing backend-specific clients,etc. Few months ago,we wanted to see if we can unify the existing solutions and use a single set of unified API and utilities to back the current tracing providers. Our main goals were to:

  • Defrag the ecosystem and make instrumentation portable regardless of which tracing backend users depend on.
  • Enable the library ecosystem to utilize the current trace context if any without having to depend on a specific tracing backend.

It soon became clear that there are two critical barriers to achieve a common API:

  • Tracing is a multi language problem. Our design decisions needs to be reflected in other language ecosystems to provide a proper end-to-end tracing solution. As the Go authors,it is beyond our scope.
  • Tracing backends and their data models are still widely different and achieving a common API that covers 80-90% of the use-cases is hard.

Additional to these critical barriers,depending on the initial research and several 1:1s we made with some of the Go users,our conclusion is that language ecosystems are suffering from the lack of a common data model and wire format rather than the lack of a common tracing library.

As we were having the initial conversation on tracing,there has been an ongoing effort in the tracing community to establish a trace context standard and a common encoding/decoding algorithm for span identifiers and the propagated labels.

As a result,our focus has shifted from achieving a common API to supporting open standard initiatives and making sure Go is well presented. We are currently collaborating to the broader tracing standardization effort. The ideal outcome of our collaboration will:

  • Allow users to propagate traces among Go and non-Go services regardless of the backend.
  • Allow users to be able to propagate traces within ecosystem libraries. Currently,trace contexts are dropped during medium/transport changes,e.g. when an HTTP request/response is wrapped by a Go API or a gRPC request is followed by an HTTP request. Provide a minimal Go building block to represent a trace context and enable the ecosystem propagating traces using that building block.
  • Allow users to be able to discover the current trace context from a context.Context.
  • Start discussion about where standard library can benefit from out-of-the-Box tracing support.
  • Establish utility libraries to make it easier to enable tracing out-of-the-Box without manual instrumentation: Tracing-enabled handlers,http.Client,and similar.
  • Enable a solution that scales both small- and large-scale in terms of performance characteristics.

Roadmap

Our roadmap is currently primarily blocked by the the emerging standards group because our priority is to align well with the tracing community and adopting their solutions rather than inventing anything Go-specific. Our next steps can be summarized as:

  • Work with the standards group to represent Go user’s concerns. If standards are not achieved or widely adopted,a backend-agnostic generic Go-specific solution will be considered.
  • Implement a trace package with the standard trace context representation and propagation primitives (e.g. propagating in context.Context and as an HTTP header) .
  • Open a discussion in the community to utilize the trace propagation package,help current tracing libraries to adopt these types where possible. Open discussion for the standard library tracing support.

The following sections will give more details about the specifics of the work required for some items.

Trace context

In a tracing system,trace context is the smallest state carrying object. It identifies a unit of work and carries labels that represent additional metrics/data in the scope of a the work.

Each tracing system has a trace context format and a spec how it should be carried in wire (e.g. via an HTTP request). An example of a trace context propagated via an HTTP header:

GET /service HTTP/1.1
    Trace-Id: 4bf92f3577b34da6a3ce929d0e0e4736/e1;o=0

Today,trace context formats are often incompatible with each other; a context generated from a tracing backend cannot be parsed by another one. Compatibility issues restrict users to depend on a single backend end-to-end and use backend-specific instrumentation libraries to utilize the trace context.

Until a standard establishes,the trace context can only be represented by an identifier and a labels byte slice that both can later be parsed by the backend specific instrumentation libraries; given backend-specific library is the only layer kNows about the encoding/decoding algorithm.

package trace

// Span represents a unit of work.
//
// ID identifies a span globally in a tracing system.
// Annotations return the labels propagated with the span.
// Encoding algorithm might be tracing-backend specific.
type Span interface{
    ID() []byte
    Labels() []byte
}

This overly generic representation of trace context is not very useful,especially for the library ecosystem that wants to instrument code (e.g. creating new child spans,attaching additional labels) without any dependencies to specific backends.

At this point,we propose to contribute to the establishment of the industry-wide wire standard and draft our design according to this standard rather than inventing a Go-specific representation. The outcome of this work will be:

  • A span context encoding format standard that is well accepted by top tracing backends.
  • A concrete span context type,and encoders/decoders in Go.

Propagation via context.Context

Being able to discover the trace contexts from the current context also is widely required. By blessing a canonical way to access trace context,we are enabling different libraries cooperate on the same trace.

package trace

// NewContext returns a derived span from the current context.
func NewContext(ctx context.Context,s Span) context.Context

// FromContext returns the span contained in the context or nil.
func FromContext(ctx context.Context) Span

Standard library support

If the proposed trace package gets into the standard library,with the first-class availability,we may be able to enable tracing support for some of the existing packages.

For example,net/http package can automatically extract the trace context from incoming HTTP request’s headers and put it in the request context. Similarly,it can inject trace context header if the request context contains a trace context.

We will open discussions and follow up with proposals once there is a trace package.

Caveats

  • We cannot foresee when an open context trace standard will be mature and finalized. Before such standard is finalized,we are blocked on designing the trace context type.
  • There are already several custom trace context types contributed by the community,e.g. OpenTracing’s SpanContext. unifying the APIs around the new type will require a lot of consensus and work.
  • Propagation primitives only provide a building block. Without a fully featured solution,it is hard to pitch the building block’s itself. We need to work closely with the current tracing libraries and make sure the building block is utilized before we
  • If the tracing community cannot achieve an open standard,our generic trace context type ([]byte,[]byte) is not very useful.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


1、Golang指针 在介绍Golang指针隐式间接引用前,先简单说下Go 语言的指针 (Pointer),一个指针可以指向任何一个值的内存地址 它指向那个值的内存地址,在 32 位机器上占用 4 个字节,在 64 位机器上占用 8 个字节,并且与它所指向的值的大小无关。大致上理解如下: 变量名前的
1、概述 1.1 Protocol buffers定义 Protocol buffers 是语言中立、平台中立、可扩展的结构化数据序列化机制,就像 XML,但是它更小、更快、更简单。你只需定义一次数据的结构化方式,然后就可以使用特殊生成的源代码轻松地将结构化数据写入和读取各种数据流,支持各
判断文件是否存在,需要用到"os"包中的两个函数: os.Stat()和os.IsNotExit() func Stat(name string) (FileInfo, error) Stat返回描述文件f的FileInfo类型值。如果出错,错误底层类型是*PathError。 func IsNot
1、编译环境 OS :Loongnix-Server Linux release 8.3 CPU指令集 : loongarch64 平台 : 龙芯 go版本 : go version go1.15.6 linux/loong64 2、go和docker安装 docker安装: y
1、概述 Golang是一种强类型语言,虽然在代码中经常看到i:=12这种写法,这其实是编译器在编译期间自动做了类型推断。编译器会对数据进行类型检查,不同类型的数据不能赋值,不能在函数中传参。强类型语言有一些优势,很多的错误会在编译期间被检查出来,不像php和python等弱类型语言,很多错误只有运
1、概述 在《Golang常用语法糖》这篇博文中我们讲解Golang中常用的12种语法糖,在本文我们主要讲解下接收者方法语法糖。 在介绍Golang接收者方法语法糖前,先简单说下Go 语言的指针 (Pointer),大致上理解如下: 变量名前的 & 符号,是取变量的内存地址,不是取
1、概述 1.1 什么是gRPC RPC的全称是Remote Procedure Call,远程过程调用。RPC是一种协议,它实际是提供了一套机制,使得应用程序之间可以进行通信,而且也遵从server/client模型。使用的时候客户端调用server端提供的接口就像是调用本地的函数一样。 而gRP
1、概述 在Golang语言中,函数也是一种数据类型,可以赋值给一个变量,则该变量就是一个函数类型的变量了。通过该变量可以对函数调用。 2、Go语言函数变量详解 定义 func fun() { } var f func() f = fun 说明 我们首先定义了一个 fun 的函数,接着我们声明了一个
1、概述 Swagger是全球最大的OpenAPI规范(OAS)API开发工具框架,支持从设计和文档到测试和部署的整个API生命周期的开发。Swagger是目前最受欢迎的RESTful Api文档生成工具之一,主要的原因如下: 跨平台、跨语言的支持 强大的社区 生态圈 Swagger Tools(S
1、 概述 Protocol buffers 是语言中立、平台中立、可扩展的结构化数据序列化机制,就像 XML,但是它更小、更快、更简单。你只需定义一次数据的结构化方式,然后就可以使用特殊生成的源代码轻松地将结构化数据写入和读取各种数据流,支持各种语言。因为profobuf是二进制数据格式,需要编码
1、名字由来 语法糖(Syntactic sugar)的概念是由英国计算机科学家彼得·兰丁提出的,用于表示编程语言中的某种类型的语法,这些语法不会影响功能,但使用起来却很方便。语法糖,也称糖语法,这些语法不仅不会影响功能,编译后的结果跟不使用语法糖也一样。语法糖,有可能让代码编写变得简单,
一、for循环 循环:让程序多次执行相同的代码块for循环是Go语言中唯一一个循环结构for循环经典语法先执行表达式1执行表达式2判断是否成立,如果成立执行循环体循环体执行完成后,执行表达式3再次执行表达式2,判断是否成立.for循环用的最多的地方就是遍历数组或切片等 for 表达式1;表达式2;表
1、概述 在Go语言中,函数可以有命名返回值和普通(匿名)返回值。命名返回值会被视为定义在函数顶部的变量,并且在使用 return 语句返回时,不再必须在其后面指定参数名,也就是支持“裸”返回;而使用普通返回值时,使用 return 语句返回时,需要在其后面指定与普通返回值相同类型的参数名。 实际上
1、概述 sync.Once 是 Golang package 中使方法只执行一次的对象实现,作用与 init 函数类似。但也有所不同。 init 函数是在文件包首次被加载的时候执行,且只执行一次 sync.Once是在代码运行中需要的时候执行,且只执行一次
1、概述 gRPC常用于服务端之间的相互调用,如果想把服务暴露给前端,虽然动手修改服务端也能实现,但似乎增加了不少工作量,此时还可以选择gRPC-Gateway方式来快速将gRPC服务以http的方式暴露出来; gRPC-Gateway 是 Google protocol buffers compi
1、初识 errgroup WaitGroup 主要用于控制任务组下的并发子任务。它的具体做法就是,子任务 goroutine 执行前通过 Add 方法添加任务数目,子任务 goroutine 结束时调用 Done 标记已完成任务数,主任务 goroutine 通过 Wait 方法等待所有的任务完成
在 Golang 里, _ (下划线)是个特殊的标识符,有以下三种用法。 1、忽略返回值 这个应该是最简单的用途,比如某个函数返回三个参数,但是我们只需要其中的两个,另外一个参数可以忽略,这样的话代码可以这样写: v1, v2, _ := function(...) 2、用在变量
1、问题 构建fluentbit-operator工程manager模块docker镜像时报如下错误: ....... Step 5/15 : RUN go mod download > Running in c54961171660 go: github.com/fsnotify/fsnot
1、自定义类型 在Go语言中有一些基本的数据类型,如string、整型、浮点型、布尔等数据类型,Go语言中可以使用type关键字来定义自定义类型。 自定义类型是定义了一个全新的类型。我们可以基于内置的基本类型定义,也可以通过struct或者函数类型来定义。 //将KubeInt定义为int类型 ty
GO语言heap剖析 本节内容 heap使用 heap提供的方法 heap源码剖析 利用heap实现优先级队列 1. heap使用 在go语言的标准库container中,实现了三种数据类型:heap,list,ring,list在前面一篇文章中已经写了,现在要写的是heap(堆)的源码剖析。 首先