Try
↑ ↓ move↵ openesc close
In this lesson · topic 3 of 7
  1. 1. Why one request needs a trace
  2. 2. Spans, context and the critical path
  3. 3. Reshape a service tree, then sample it
  4. 4. When one slow call in a hundred reaches most requests
  5. 5. Traces that cross a queue
  6. 6. What a tail sampler costs to run
  7. 7. Off-path spans, 100 backends, keeping slow traces

Topic 3

Reshape a service tree, then sample it

8 min read

A service tree you can reshape

The lab builds requests that fan out across tiers of services. You set the depth, the fan-out and whether calls are parallel, sequential or alternating. Each call has its own latency, and a small share of calls take a slow path. Every request becomes a trace of spans.

The waterfall shows one trace at a time. Filled bars are time on the critical path. Below it, the tail-at-scale chart and the sampler comparison read the whole stream.

Predict before you press play

A head sampler keeps ten percent of traces at random. A tail sampler keeps every slow trace. Across the same traffic, how many slow traces does each keep?

13 spans per request (12 calls below the gateway)typical 68.6 msslow trace: over 137 ms

p50
75.7 ms
p95
181 ms
p99
258 ms
slow traces
9%
slowest call on path
74%

One trace, drawn as a waterfall

Which trace to draw
0.0 ms38.7 ms77.4 ms116 ms155 msgateway155 mscatalog68.4 msindex22.1 mscache13.9 msdb22.6 mspricing47.3 msindex11.7 mscache7.9 msdb13.8 mssearch151 msindex14.4 mscache19.9 msdb111 msslowest, on path

Filled bars are time spent on the critical path. Outlined bars finish while something else is still running. A red outline marks a call that took its slow path.

The filled parts add up to 155 ms, which is the end-to-end latency of 155 ms. The slowest call by its own time is db (111 ms), and it is on the critical path.

The tail at scale

Chance a request waits on at least one slow call
Chance a request waits on at least one slow call. Text version available below the chart.0%25%50%75%100%N=1N=10N=100parallel calls per request, Nshare of requests
Share of requests with at least one slow call, measured and from the formula
N125102050100
Measured1%2%5%11%19%39%64%
Formula1%2%5%10%18%39%63%

Measured over 600 requests for each N. A request is slow here if at least one of its N parallel calls took the slow path, which one call in 100 does. In the call tree above, 11.7% of requests had at least one slow call, and 1 - (1 - p)12 predicts 11.4%.

What each sampler keeps

Head sampling

Decides at the first span, before the outcome is known. Keeps 10% of traces at random.

stored
134 of 1200
slow traces kept
8%
kept that are slow
6%

Tail sampling

Decides once the trace is complete. Keeps every slow trace and 2% of the rest.

stored
130 of 1200
slow traces kept
100%
kept that are slow
82%

Full-page version with guided experiments: Distributed tracing lab.

Things to try

  1. In the waterfall, choose the trace where the slowest call is off the critical path. Find the call marked as the slowest, and find the filled bars.
  2. Change the call pattern to all sequential. Every span moves onto the critical path.
  3. Raise depth and fan-out together. Read the number of calls below the gateway and the share of slow requests.
  4. Raise slow calls to 5 percent. The measured points on the tail-at-scale chart stay on the curve.
  5. Lower the head sampling rate to 5 percent. Compare the slow traces each sampler keeps.

Open the full-page lab for five ready-made experiments.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms