Tracing & Performance

Reading Span Waterfalls Like an Expert

A span waterfall shows where every millisecond of a request went. Learn to read one, spot the critical path, and find the service causing latency.

When a user clicks a button and waits for a response, they're not waiting for one operation — they're waiting for a cascade. A request hits your API, which talks to a database, which talks to a cache, which maybe calls a third-party service. Every step takes time, and every millisecond adds up. A span waterfall is a visualization that shows you exactly where time goes, service by service, so you can find the one step that's actually slow.

Without a waterfall, you see only the total latency: "the request took 800 ms." With one, you see the truth: "it took 200 ms to get to the database, 500 ms to run the query, 50 ms to serialize the response, and 50 ms of network overhead." That breakdown is the difference between guessing and knowing what to optimize next.

What a span waterfall actually shows

A span waterfall is a timeline view of distributed tracing. Each horizontal bar represents a span — a unit of work like "fetch user from DB" or "call payment API." Spans are nested: a top-level request span contains child spans for database calls, cache checks, and third-party requests. The position of each bar shows when it started, and the width shows how long it took.

Time flows left to right. If one span starts after another ends, they were sequential — the second one had to wait. If they overlap, they ran in parallel, so both times added up to the wall-clock time, not the sum. A span waterfall lets you see both patterns instantly.

A span is a named, timed operation. A trace is the full tree of spans for a single request. LightTrace captures traces automatically when you use the Sentry SDK with tracesSampleRate: 1.0.

The most useful waterfalls also color-code spans by service. In a microservices architecture, one request might touch five services. If you see a span from "payment-service" that's twice as wide as the others, you've just found your bottleneck — and you know exactly which team to talk to.

Reading a waterfall from top to bottom

Start with the root span: the outermost bar that shows total latency. Below it are child spans, indented to show the hierarchy. Read from the top down to trace the path of the request:

  1. Root span — the HTTP request from client to your entry point. Its total width is what the user experienced.
  2. First-level children — the major operations your handler kicked off. If you see a database query, a cache check, and an external API call, they'd all be here.
  3. Nested children — any work inside those operations. If your database query itself called a connection pool, or a third-party API had retries, those show as deeper levels.

The waterfall works because it's instant pattern recognition. A wide bar is obviously slow. A dense cluster of bars on top of each other means sequential work that could be parallelized. A gap between bars means one operation finished before the next started, leaving idle time.

The critical path: The thing that actually matters

Not all spans matter equally. The critical path is the sequence of spans that, if any one of them got slower, would make the whole request slower. It's the chain with no parallelism hiding it.

Look at your waterfall and trace a path from root to the deepest leaf that has no overlapping siblings. That's your critical path. If you have:

  • Request hits API (0–800 ms)
    • Fetch user from DB (0–200 ms)
      • Query runs (5–195 ms)
    • Fetch posts from DB (200–700 ms)
      • Query runs (205–695 ms)

Then the second fetch is on the critical path: the request can't finish until both fetches finish, and the second one takes longer. Speeding up the first fetch helps, but only a little. Speeding up the second one directly helps the user.

To optimize latency, focus on the critical path first. Parallelizing off-path work doesn't help the user experience; shortening the critical path does.

Spot the bottleneck: Common patterns in span waterfalls

A good waterfall tells a story. Here are the patterns that usually mean something needs fixing:

The long tail. One span is obviously wider than the rest — maybe a database query, maybe an external API call. That's your target. Optimize that query, add caching, or replace that slow API.

The serial wall. You see a stack of bars, each starting when the previous one ends, taking up 80% of the total time. Those operations should probably be parallelized. If you're fetching user, then posts, then comments sequentially, fetch all three at once.

The surprise service. In a microservices setup, one service's span is unexpectedly slow — or there are way more spans from it than you'd expect (retries, cascading calls). That's a regression waiting to be caught.

The idle gap. There's a visible gap between when one span ends and the next begins. You're waiting for something — for a resource to free up, for a queue to drain, for a lock to release. Watch these in prod; they often correlate with load spikes.

The N+1 query. You see 50 identical short database spans, stacked on top of each other. You're executing one query per item instead of one query for all items. This is so common it gets its own deep dive at the N+1 query problem.

When waterfalls go wide vs deep: Understanding span structure

A deep waterfall (many levels of nesting) usually means: your request flows through many layers of code, each one calling the next. Deep isn't inherently bad, but it's worth checking that each layer is doing real work and not just passing the request down.

A wide waterfall (many spans at the same level) usually means: your code is doing many things in parallel, or your handler is making many independent calls. That's usually good for latency — parallelism is fast. But watch for redundant fetches. If you see five spans fetching slightly different slices of the same resource, you're probably missing a cache or N+1 opportunity.

The view-time difference: From traces to actionable fixes

LightTrace displays span waterfalls directly in the dashboard. Click into any slow transaction, and you'll see the waterfall for that one request. But the real power comes from patterns across many requests:

  • Percentile view. See the p95 waterfall (the 95th slowest request) to understand where typical slow requests lose time, separate from the few rare worst-case ones.
  • Comparison. Compare the waterfall of a slow request to a fast one and spot what's different.
  • Historical trends. If a span that used to take 50 ms now takes 500 ms, you've likely found what changed in the last deploy.

This is why distributed tracing matters. A single fast request tells you nothing. But aggregating traces across thousands of requests reveals patterns you can actually act on.

From waterfalls to action: Fixing bottlenecks across services

Reading a span waterfall is the detective work. Actually fixing latency is the next step. The waterfall tells you what is slow; you decide how to make it fast. Common moves:

  • Add caching if you're fetching the same data repeatedly.
  • Parallelize if you're doing sequential work that doesn't depend on each other.
  • Optimize the query if a database span is the bottleneck.
  • Switch providers or add a retry policy if an external API is flaky.
  • Profile locally using the stack trace if the slow operation is in your own code.

The key insight is: you can only fix what you can see. Waterfalls make the invisible visible.

Not all slow requests are the same. A single outlier with a slow external API tells a different story than 10,000 requests all slow in the same way. Always check the percentile and the count.

In microservices architectures, a single user request often spans multiple services. If service A calls service B which calls service C, the waterfall stitches them together with trace IDs and span IDs. LightTrace's cross-project tracing feature means you can see a single waterfall across all your services, even if they're instrumented separately.

That's the game-changer: you don't have to jump between dashboards to debug latency. The waterfall shows you the whole path, and you see at a glance which service introduced the slowness. Then you can reduce API latency with the confidence that you're optimizing the right thing.

Start tracking errors in minutes

See your first span waterfalls in minutes by pointing the Sentry SDK at LightTrace — spot bottlenecks, find the critical path, and ship faster APIs.

Waterfalls won't fix slow code, but they'll save you hours of guessing. Start capturing traces, and the next slow transaction becomes a roadmap instead of a mystery.

Fix your next production error faster

Point any Sentry SDK at LightTrace — free up to 5,000 events/month.