Start free trial
Start free trial Log in

14-day free trial. No credit card.

What is a trace?

  • Glossary
  • 3 minute read

What is a trace in observability?

A trace is the full record of one request's journey through your system: every operation it triggered, in order, with durations. Traces are trees of spans sharing a single trace ID, rendered as waterfall diagrams so you can see at a glance which step ate the time budget. Laravel's nightwatch package records a complete per-request trace automatically; NightOwl renders the waterfall in its request detail view.

Updated

Before traces, finding a slow request meant reproducing it locally and hoping your laptop behaved like production. A trace removes the hoping. It records what one real request actually did, step by step, with a number next to each step, so "the checkout page is slow" becomes "this one query took 820 of the 980 milliseconds."

The shape of a trace

A trace is a tree. The root span is the whole request. Child spans are the operations that ran inside it. Each span has a start time, end time, and optional parent pointer.

A simplified Laravel trace
POST /api/checkout                        [root, 980ms]
├── middleware.auth                       [3ms]
├── middleware.throttle                   [1ms]
├── Controller@store                      [970ms]
│   ├── db.query SELECT user              [4ms]
│   ├── db.query SELECT cart WITH items   [820ms]   ← the bottleneck
│   ├── http.out stripe.com/v1/charges    [130ms]
│   └── view.render checkout.success      [12ms]
└── response.send                         [2ms]

At a glance you can see db.query SELECT cart WITH items owns 84% of the request. You drill in and inspect the SQL, see that one query is loading every cart row in the table instead of this user's cart, and fix it.

Trace IDs and span IDs

Every span carries a trace ID (shared across the whole trace) and its own span ID. Parent-child pointers rebuild the tree. In a multi-service architecture, trace IDs propagate between services via HTTP headers (traceparent) so spans from different services stitch into one trace.

Traces within a Laravel monolith

Every Laravel request is already a trace once instrumented. The Nightwatch package auto-instruments the framework's common operations (DB queries, cache, mail, queue dispatches, outgoing HTTP) and ties them back to the originating request. NightOwl and Laravel Nightwatch Cloud both consume this data and render the waterfall.

What traces don't solve

  • Aggregation: one trace tells you about one request. For patterns you still need aggregated metrics (p95 per route).
  • Long-running work: queue jobs after the HTTP response need their own trace or a linked span.
  • Cost: storing every trace at high traffic takes space. Tools that bill per event usually push you to sample; NightOwl keeps every request by default because the data sits in your own PostgreSQL.

Reading a waterfall fast

The skill is less about the tooling and more about where to look. Two heuristics carry most of the weight.

Look for the widest bar, not the deepest tree. A trace with forty spans is intimidating until you notice one of them owns 80% of the width. That bar is your bottleneck; the other thirty-nine are noise for this particular investigation.

Then look for things that run in sequence but could run in parallel. Three external API calls stacked end to end, 100ms each, is 300ms you might collapse to 100ms by firing them concurrently. The waterfall makes that obvious in a way the code doesn't, because the code reads fine and only the timing gives it away.

See the waterfall for any request in your app

NightOwl draws every request as a waterfall of its queries, cache calls, outgoing HTTP, mail and dispatched jobs, recorded by the Nightwatch package. It keeps every request by default, so the slow one you're chasing is there to open.

No credit card needed.

Frequently asked questions

Anything else, write to support@usenightowl.com

What is a trace in observability?

A trace is the full record of one request's journey through your system: every operation it triggered, in order, with durations. Represented as a tree of spans sharing a trace ID. Tracing tools render traces as waterfall diagrams so you can see at a glance which step ate the time budget.

What's the difference between a trace, a span, and a log?

A trace is the whole request. A span is one operation inside the trace (a DB query, an HTTP call, a function). A log is a free-text event associated with a point in time. Spans have start/end timestamps and parent-child relationships; logs don't. Traces are structured; logs are ad hoc. Modern observability correlates all three: a log within a span within a trace.

How long should I keep traces?

Depends on storage cost. A full trace holds many spans, so it is usually much larger than a single log line for the same request. A common pattern is to keep raw traces for a week or two and aggregated metrics (request counts, percentiles per endpoint) for months. Tail-sampling (keep only interesting traces like errors and slow requests) can cut storage a lot, depending on how much traffic your rules keep.

Do I need to instrument every call to get useful traces?

You want enough to find bottlenecks. At minimum: HTTP receipt + DB queries + external HTTP + cache calls + queued job dispatch. Laravel's nightwatch package covers all of these automatically. When the framework-level view isn't enough, a tracing SDK such as OpenTelemetry lets you add custom spans around expensive internal operations (image processing, PDF rendering); the Nightwatch package doesn't record custom spans.

Is a trace the same as an APM transaction?

Functionally yes, naming varies. 'Transaction' is New Relic's term (and older Sentry's) for a top-level span grouping everything inside one request. 'Trace' is the OpenTelemetry-era term. Same idea: the root span with children. Different vendors also use 'web request,' 'operation,' or just 'request.'

How do traces help debug Laravel apps?

A trace turns 'the checkout page is slow' into a waterfall showing: the auth middleware took 3ms, the cart query took 820ms (here's your bottleneck), the Stripe API call took 130ms, view rendering 12ms. You point at the problem instead of guessing. Without traces you'd profile locally and hope to reproduce.

Keep reading

Flat pricing, whatever your traffic does

Every plan starts with a 14-day free trial. No credit card needed.

Hobby
$5 a month

One app for a side project. Issues and alerts, with a 14-day dashboard window.

Start my 14-day trial
TeamRecommended
$15 a month

Up to 3 apps and 5 people per team. Full history, the MCP server, data clearing and agent health.

Start my 14-day trial
Agency
$69 a month

Unlimited client apps and people, one overview of every app, and apps you can hand over.

Start my 14-day trial