{"canonical_url":"https://engineer.company/glossary/distributed-tracing/","content_markdown":"# Distributed tracing\n\n## What it is\n\nDistributed tracing follows what happens to an operation as it crosses process\nor service boundaries. A trace groups related spans. A span records one piece of\nwork, such as accepting an HTTP request, querying a database or calling an\ninventory service. It generally has a start and end time and can hold selected\nattributes and status. A parent span explains one causal relationship. Span\nlinks can represent relationships that do not fit a simple parent and child\ntree, such as a batch assembled from several requests.\n\nTrace context lets instruments associate work in different processes. Over HTTP,\nthe W3C Trace Context specification describes headers including traceparent,\nwhich carries identifiers and flags. The receiving component can use this\ninformation to start its own span in the right trace. A queue can also carry\ncontext in message metadata when its instrumentation supports the transport.\nTrace context is an operational correlation mechanism, and the trust placed in\nincoming data still depends on the service boundary.\n\nIn a checkout, a web service might request a quote and reserve inventory before\nresponding. The trace can show that the calls ran in parallel and that a wait\nfor inventory dominated the response. A later worker can link its own span to\nthe operation that scheduled it. The resulting view helps someone ask which work\ndelayed this transaction. Aggregate metrics help answer how often the problem\nhappens and how much of the workload it affects.\n\nAn investigation can also use the absence of an expected span as a clue. First\nestablish how that span would have been recorded and whether the trace passed\nthrough sampling and export. A healthy test transaction is useful as a positive\ncontrol. Trigger the same application route and verify that its expected spans\nreach the backend. If they do, compare the affected route's flags, dependencies\nand time range with the control before drawing conclusions about the missing\nwork.\n\n## Why it matters\n\nTiming each component separately can obscure how they combine from the caller's\npoint of view. A service that appears fast on average can hold up a particular\nrequest during a retry or long queue wait. A trace gives evidence about the\nparticular route, its dependencies and the relationship between two delays.\nCompare it with latency distributions and error metrics so an isolated slow\nsample is interpreted in the context of the rest of the workload.\n\nContext propagation is especially useful when a job moves between teams. The\nrequest handler can record that a job was queued. The worker then handles the\njob under another process and may fail after the original request succeeded. If\nthe context crosses the queue boundary, support staff can relate the activity\nwithout guessing from timestamps. Define which identifiers have an operational\npurpose and how someone finds them without exposing payloads or personal data.\n\nInstrumentation adds processing, storage and operational costs. A sampling\nstrategy chooses how much data to collect or retain. A decision near the start\ncan reduce work early. A collector that decides near the end can retain traces\nbased on observed error or latency, with different buffering and capacity\nrequirements. Set the sampling policy according to the questions the team\nactually needs to answer. Also measure the loss that can happen before the\ndecision, including unavailable collectors and partial instrumentation.\n\n## What it looks like in practice\n\nChoose one transaction with a clear outcome and instrument it from the service\nentry to its important dependencies. In a test, trigger normal traffic, a slow\nprovider response and a broker redelivery. For each trace, inspect the span\nnames, timestamps and relationship to the calling operation. Confirm that a\ndeveloper can tell whether time was spent waiting for capacity or executing the\nwork. Try a service interruption and examine what still arrives at the\ncollector.\n\nReview which attributes the instrumentation sends. A trace can contain the route\ntemplate, an outcome category and the component name. It rarely needs the\noriginal email address, a request body or an authentication header. Test trace\nlookup after removing such data and check the policy at the collector as well as\nthe client. If operators need to find a specific transaction, choose an opaque\nidentifier with a justified retention period and document who can use it.\n\nOur\n[case study on the company's first observability dashboard](/portfolio/built-the-companys-first-observability-dashboard/)\ndescribes collecting infrastructure and container measurements and later using\nGrafana and Prometheus. Such measurements give context when a trace shows delay\nduring a deployment or resource spike. The checkout scenario illustrates how\ntracing can add information about the path of one request. The dashboard case\nsupplies the aggregate monitoring example.\n\n## Where it goes wrong\n\nMissing propagation can split one request into unrelated trace records. Verify\nboth ends of a process boundary and follow the actual transport. Check that a\nproxy forwards the relevant fields and that instrumentation does not create a\nnew root span by accident. Include asynchronous work in the test. A visible\nserver span confirms that one component was instrumented, while the relationship\nto its producer needs its own check.\n\nA detailed trace can still represent an incomplete or biased sample. Services\ncan drop spans at different points, clocks can disagree and long-running work\ncan finish after a collector gives up waiting. Document how instrumentation and\nsampling affect what appears. When a backend reports a missing time window, look\nfor span loss and clock problems before concluding that the operation had no\ncorresponding work.\n\nAttributes with a unique value for almost every request can become costly to\nindex. Use stable span names and dimensions suited to the questions each backend\nanswers. Restrict who can search and export trace data, especially when it\ncrosses organisation boundaries. Test the storage and ingest cost during bursts.\nThe telemetry path should tolerate delay or loss according to a documented\npolicy while the application continues to serve its primary purpose.\n\n## Further reading\n\n- [OpenTelemetry traces](https://opentelemetry.io/docs/concepts/signals/traces/)\n  explains spans, relationships and trace context.\n- [W3C Trace Context](https://www.w3.org/TR/trace-context/) specifies HTTP\n  headers for interoperable trace propagation.\n- [OpenTelemetry sampling](https://opentelemetry.io/docs/concepts/sampling/)\n  describes head and tail sampling and the evidence each can use.\n\n\u003chttps://engineer.company/glossary/distributed-tracing/\u003e\n","date_modified":"2026-11-24T21:48:58Z","description":"How spans show a request's path, what sampling changes, and how to check context across service boundaries.","formats":{"gemtext":"https://engineer.company/glossary/distributed-tracing/index.gmi","gopher":"https://engineer.company/glossary/distributed-tracing/gophermap","html":"https://engineer.company/glossary/distributed-tracing/","json":"https://engineer.company/glossary/distributed-tracing/index.json","markdown":"https://engineer.company/glossary/distributed-tracing/index.md","pdf":"https://engineer.company/glossary/distributed-tracing/index.pdf"},"kind":"page","language":"en","title":"What is distributed tracing?","url":"https://engineer.company/glossary/distributed-tracing/","version":1}