Dapper, a Large-Scale Distributed Systems Tracing Infrastructure

分布式追踪的鼻祖文章。介绍spans、traces的概念。通过对common facilities的手动修改插桩实现分布式追踪。

Applications are constructed from collections of software modules that may be developed by different teams, perhaps in different programming languages, and could span many thousands of machines across multiple physical facilities. Dapper就是为了解决针对这些applications的understanding system behavior and reasoning about performance issues。

两个最重要的goal:ubiquitous deployment和continuous monitoring。 这两个goal导致了三个要求:Low overhead、Application-level transparency(用户感觉不到)、Scalability。

本文最大的设计难点在于true application-level transparency。 是通过restricting Dapper’s core tracing instrumentation to a small corpus of ubiquitous threading, control flow, and RPC library code实现的

Distributed Tracing in Dapper

这句话很重要: since all applications use the same threading model, control flow and RPC system, we found that it was possible to restrict instrumentation to a small set of common libraries

Trace trees and spans

对trace trees、spans进行了概念性的介绍

Instrumentation points

分成三个部分

  1. 在thread-local storage增加trace context
  2. Google的开发者用同一个control flow库,因此可以在callback中保存creator的trace context,并和调用callback的线程联系起来,解决异步问题
  3. Google的开发者都用gRPC,因此在gRPC插桩

Annotations

可以在代码里增加annotations来增加自定义桩点。有两种

  • timestamped, textual annotations
  • a map of key-value annotations

Sampling

支持sampling

Trace collection

Trace collection分成三步:每个instrumented binaries写log file;Dapper daemon把他们pull出来;放Bigtable里,一行是一个trace。

实现out-of-band的trace collection出于两个原因

  1. 不影响性能
  2. in-band意味着span的生命周期和message强绑定,但情况并不是这样。很多RPC不是perfectly nested的

Security and privacy considerations

由于安全和隐私问题是不可协商的,Dapper存储RPC方法的名称,但此时不记录任何有效载荷数据。 如果真的要一些和逻辑相关的信息,用户可以选择使用annotations。

Dapper Deployment Status

Dapper runtime library

少于1000行的C++、少于800行的Java、annotations又加了500行代码

Production coverage

并没有准确数字,而是估计基本上每台机器、每个进程都用了。

然后讲了一些其他的事情,比如dapper不能够覆盖一些特殊情况,dapper可以被关闭等等。

Use of trace annotations

70% of all Dapper spans and 90% of all Dapper traces have at least one application-specified annotation. annotations被程序员用来做分布式log或者分类trace用;java程序员用annotation多一些。

Managing Tracing Overhead

evaluation,包括trace生成开销、trace收集开销、对生产环境workload的影响、采样。

General-Purpose Dapper Tools

The Dapper Depot API

Dapper "Depot API",或DAPI,提供对regional Dapper存储库(或 "Depots")中分布式trace的直接访问。 可以通过trace id、批量访问、通过索引访问。

The Dapper user interface

介绍了一下GUI。

Experiences

Using Dapper during development

一个来自于Google AdWords的例子。包括Dapper带来的帮助、使用的一些细节、不足之处、最终效果 (Ads Review团队估计,使用从Dapper追踪平台收集到的数据,他们的延迟数字已经提高了两个数量级)

此外还与Google的异常监测平台整合。

Addressing long tail latency

long tail latency debugging的工程师使用Dapper,有了一些对系统的理解。

Inferring service dependencies

Google的Service Dependencies用了Dapper

Network usage of different services

应用级的集群间网络活动分析任务

Layered and Shared Storage Systems

分层共享的存储系统中,要确定最终用户的资源消耗模式并不容易。使用Dapper进行汇总、排名。

Firefighting with Dapper

在一些紧急情况下,可以直接在Dapper daemon上查看数据。

Other Lessons Learned

其实是讲不足之处:

  • 没法处理buffer
  • batching而不是一个一个的request(因为dapper是每个request给一个id)
  • 找到的是直接原因不是根本原因(比如排队)
  • kernel信息