Learning center

Which observation separates two explanations of the same symptom?

Write down what each explanation predicts for one observation you have not read yet, and read the observation where the predictions disagree. A graph that every explanation predicts, such as total p99 latency rising, cannot choose between them however long you look at it. One that only one explanation predicts, such as /search getting slower on the new release while /item and the database stay flat, can prove that explanation wrong in a minute.

The symptom and three explanations#

A fictional catalog service shipped release v42 beside v41 at 14:00 UTC, half the traffic each. By 14:20 the dashboard's p99 latency had gone from about 150 ms to about 280 ms, and three people in the incident channel had three explanations:

  • The release: v42 changed the search code, and searches got slower.
  • The traffic mix: a newsletter went out at 14:00, and the extra traffic is mostly searches, which were always the slow requests.
  • The database: the database both releases share got slower at about the same time.

All three predict the graph everyone is looking at. Rolling back would end the argument for the first explanation only if the newsletter traffic and the database also happened to settle at that minute. Does a rollback prove the release caused it?

Four steps that make a check able to fail#

  1. Name every explanation still standing, including the dull ones: a change in what users send, a shared dependency, the telemetry itself. An explanation nobody writes down is never tested.
  2. For each one, write the prediction it makes for observations nobody has read yet. Write it as a direction and a place: "p99 of /search on v42 above v41 in the same minutes," not "search is slow."
  3. Pick the observation where the predictions differ the most, and that you can read soonest. An observation where all explanations predict the same value is worth nothing for this decision, however alarming it looks.
  4. Record the predictions before you read the data, in the incident channel or the timeline, with the time. A prediction written after the graph is open bends to fit it.

For the catalog symptom, the predictions are:

ObservationReleaseTraffic mixDatabase
Total p99, both releasesrisesrisesrises
p99 of /search, v42 against v41, same minutesv42 higherequalequal
p99 of /item, both releasesunchangedunchangedrises
Share of requests that are /searchunchangedrisesunchanged
Time spent in database callsunchangedunchangedrises

The first row is where the incident channel was looking, and it separates nothing. The rows below it each split one explanation from the other two. Reading the second and the fourth together is enough to rule out two of the three.

The lab: three worlds, one dashboard#

The script builds 20,000 requests in each of four worlds: a baseline, and one for each explanation. In every world half the requests go to v41 and half to v42. A /search request spends more time in the application than an /item request, and both spend time in the database. It needs Python 3.8 or later and nothing else.

import random, statistics, sys

def requests(world, n=20000, seed=7):
    rng = random.Random(seed)
    for _ in range(n):
        rev = rng.choice(["v41", "v42"])
        heavy = 0.30 if world == "mix" else 0.10
        route = "/search" if rng.random() < heavy else "/item"
        db = rng.lognormvariate(3.0, 0.4)            # ms spent in the database
        if world == "dependency":
            db *= 2.5                                 # the database got slower for everyone
        app = rng.lognormvariate(2.5 if route == "/item" else 4.5, 0.3)
        if world == "release" and rev == "v42" and route == "/search":
            app *= 3                                  # v42 made /search slower
        yield rev, route, db, app + db

def p99(xs):
    return statistics.quantiles(xs, n=100)[98]

if len(sys.argv) < 2 or sys.argv[1] not in ("baseline", "release", "mix", "dependency"):
    sys.exit("usage: python3 separate.py baseline|release|mix|dependency")
world = sys.argv[1]
rows = list(requests(world))
print(f"world={world}")
for rev in ("v41", "v42"):
    mine = [r for r in rows if r[0] == rev]
    share = sum(r[1] == "/search" for r in mine) / len(mine)
    by_route = {route: p99([r[3] for r in mine if r[1] == route]) for route in ("/item", "/search")}
    db = p99([r[2] for r in mine])
    print(f"  {rev}: all p99 {p99([r[3] for r in mine]):6.0f} ms | /item p99 {by_route['/item']:5.0f} | "
          f"/search p99 {by_route['/search']:5.0f} | /search share {share:4.0%} | db p99 {db:4.0f}")

Save it as separate.py, then run each world:

for world in baseline release mix dependency; do python3 separate.py "$world"; done

Before you run it, write down which column will move in each world. Python 3.11 printed:

world=baseline
  v41: all p99    149 ms | /item p99    65 | /search p99   200 | /search share  10% | db p99   50
  v42: all p99    153 ms | /item p99    64 | /search p99   214 | /search share  10% | db p99   51
world=release
  v41: all p99    149 ms | /item p99    65 | /search p99   200 | /search share  10% | db p99   50
  v42: all p99    412 ms | /item p99    64 | /search p99   590 | /search share  10% | db p99   51
world=mix
  v41: all p99    180 ms | /item p99    65 | /search p99   203 | /search share  31% | db p99   50
  v42: all p99    176 ms | /item p99    64 | /search p99   208 | /search share  30% | db p99   51
world=dependency
  v41: all p99    193 ms | /item p99   138 | /search p99   236 | /search share  10% | db p99  125
  v42: all p99    194 ms | /item p99   140 | /search p99   261 | /search share  10% | db p99  126

The "all p99" column rose in all three worlds. Each world moved a different one of the other columns: /search on v42 alone in the release world, the /search share alone in the mix world, and /item with the database time in the dependency world. The numbers depend on the seed; the pattern does not. Change seed=7 to any other value and the same columns move.

The lab also shows a trap. In the mix world, total p99 rose by about 30 ms with no request getting slower at all, because more of the requests were the slow kind. A dashboard that shows only total percentiles turns a change in what users send into what looks like a regression. p99 rose and p50 stayed flat: queueing, or a slow subset?

Read the same observations on a real system#

The observations need latency split by route and by release, a request count by route, and time in the dependency. With Prometheus histograms labelled by route and version, the second row of the table is one query. histogram_quantile estimates the quantile from bucket counts, so compare the two releases' estimates rather than reading either as exact. histogram_quantile

histogram_quantile(0.99,
  sum by (le, route, version) (rate(http_server_request_duration_seconds_bucket{service="catalog"}[5m])))

The fourth row is the share of requests by route:

sum by (route) (rate(http_server_request_duration_seconds_count{service="catalog"}[5m]))
  / scalar(sum(rate(http_server_request_duration_seconds_count{service="catalog"}[5m])))

Metric and label names differ between instrumentation libraries; use your own. OpenTelemetry's HTTP conventions name the route attribute http.route and expect a low-cardinality template such as /item/{id}, not the raw path, which is what makes a split by route readable. OpenTelemetry HTTP spans The database time comes from client spans around each query, or from the database's own view of time per statement. Is the dependency slow, or the client?

When the whole fleet runs the new release, there is no second release in the same minutes to compare against. Compare the same route before and after the deploy instead, and accept that a change in the dependency or in traffic at that minute can now hide in the comparison. Two changes shipped together

The collection#

Each guide below takes one symptom with explanations that fit it equally well, gives the observation where they disagree, and a lab that produces each explanation so the prediction can fail.

Did a change cause it, and did the fix fix it?#

When the telemetry may be the problem#

Latency and saturation#

Retries, load and failures that spread#

Resources on one host#

Data that looks wrong#

Where the method runs out#

Two explanations can make the same prediction for every observation you can read today. Then the method tells you which observation to add, such as a label for the release or a span around the dependency call, and the incident review records the question as open.

An observation can be wrong in ways the explanations did not anticipate. A route label set to the raw path, a histogram whose buckets end below the latency you care about, or a dropped scrape can each make a column move or stay still for reasons that have nothing to do with the incident. The telemetry guides above treat these as explanations in their own right.

More than one explanation can be true. A slower release and a newsletter can arrive in the same hour, and then two rows move at once. The table still tells you how much each contributes, which is what a fix needs.

Ask for an investigation#

Proofline answers a production question from a pull request comment or Slack with the changes to check first. It names a likely cause only when its validation accepted one, and otherwise says that no cause was established and lists ranked leads. Ask Proofline to investigate

Questions#

Why write the predictions down before looking at the data?

A prediction made after you have seen the graph tends to match it. Writing it first, with the time, is what lets the observation prove an explanation wrong. It also shows later readers of the incident review which explanations were tested and which were only argued.

What if the observation I need is not collected?

Pick the next best observation from the table that is collected, and add the missing one as a follow-up from the incident. The guides in this collection name the label, span or counter each observation needs.

Is ruling out an explanation the same as proving another?

No. Each observation removes the explanations whose predictions it contradicts. The one left standing is the best supported so far, and the next observation where it makes a distinct prediction is its test.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading