Skip to content

Monitoring glossary

What is distributed tracing?

Distributed tracing follows a single request as it moves through services, queues and databases, so you can see exactly where the time went and which call failed.

4 min read9 sectionsUpdated

On this page

Key points

  • A trace is one request; a span is one step inside it. Spans nest to form a tree.
  • Context propagation joins services: each call carries the trace ID in a header such as W3C traceparent.
  • The waterfall view shows critical paths: the longest, deepest bars explain slow requests.
  • OpenTelemetry makes tracing portable across languages and vendors.

Why tracing exists

In a single process, a stack trace or a profiler tells you where time goes. Once a request crosses a load balancer, an API gateway, three services, a queue and two databases, no single process sees the whole story. Logs from each service exist, but stitching them together by timestamp is slow and unreliable.

Distributed tracing solves this by giving every request a trace ID at the edge and passing it along with every call. Each service records its work as spans tagged with that ID, and the tracing backend assembles them into one tree.

How it works

  1. The first service starts a trace. It creates a root span with a new 128-bit trace ID.
  2. Every unit of work becomes a span with a name, start time, duration, status and attributes such as http.route or db.statement (with values removed).
  3. Calls carry the context. Outgoing HTTP requests include a traceparent header, so the next service creates child spans in the same trace. See context propagation.
  4. Spans are exported in batches to a backend, often through an OpenTelemetry Collector.
  5. The backend assembles the trace and computes metrics from spans: request rate, error rate and latency per service and route.
plaintext
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
             │  │                                │                └ flags (01 = sampled)
             │  │                                └ parent span id (16 hex)
             │  └ trace id (32 hex)
             └ version

Reading a trace waterfall

A waterfall draws each span as a bar on a timeline, children indented under parents.

  • Look for the widest bar that has no children: that is where time was actually spent.
  • Look for repetition: 40 identical database spans in a row is an N+1 query. See how to find slow database queries.
  • Look for gaps: time inside a parent span with no child spans is time spent in your own code (or in an uninstrumented library).
  • Look at status: the first span marked as error is usually closer to the root cause than the last.

Sampling and cost

Tracing every request on a busy service is expensive. Sampling keeps a share of traces. Head sampling decides at the start (for example 10% of requests); tail sampling decides after the trace completes, which lets you keep all errors and slow requests. Use a parent-based rule so a trace is never half recorded.

Getting started

Pick the most important service, add the OpenTelemetry SDK with automatic instrumentation, and set service.name, service.version and the environment. Guides by stack: Node.js, Python, Java Spring Boot, Go, .NET and Next.js.

VitalRix APM builds latency percentiles, error rates, slow endpoints, a database view and a service map from your traces, with each chart one click from the requests behind it.

Frequently asked questions

Is distributed tracing only for microservices?

It is most valuable there, but a monolith with a database, a cache and a few external APIs benefits too: the trace shows which dependency is slow.

How much overhead does tracing add?

Usually a few percent at most. Spans are created in memory and exported in batches in the background. Sampling reduces it further on high-traffic services.

What is the difference between a trace and a log?

A log is one event. A trace is the structured story of one request, made of timed spans with parent-child relationships. Logs that carry the trace ID can be shown inside the trace.

  • Jaeger vs Zipkin: Jaeger vs Zipkin compared: architecture, storage, OpenTelemetry support, UI and operations for open-source distributed tracing, and when to pick each.
  • Microservices monitoring: a practical guide: Monitor microservices without drowning in data: consistent naming, distributed tracing, RED metrics per service, dependency views and SLO alerts.
  • OpenTelemetry: Send traces and metrics with standard OpenTelemetry SDKs or a Collector using one endpoint and an API key. No proprietary agent and no lock-in.
  • OpenTelemetry for FastAPI: Trace a FastAPI service with OpenTelemetry: instrument the app, async database drivers and httpx, run uvicorn workers correctly and export.
  • OpenTelemetry for PHP and Laravel: Trace a Laravel app with OpenTelemetry: install the PHP extension and auto-instrumentation packages, configure PHP-FPM and trace queries.
  • OpenTelemetry for NestJS: Trace a NestJS service with OpenTelemetry: load the SDK before Nest boots, instrument HTTP, Express and NestJS core, and export JSON to VitalRix.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.