Root Span and Entry Points
What you'll learn: How to identify where distributed traces begin and how entry points create the foundation for end-to-end request tracking.
Why Root Spans Matter
Every distributed trace starts somewhere—typically at the entry point of your system where external requests first arrive. The root span is the first span created for a new request, marking the beginning of the trace's hierarchy. All subsequent spans (database calls, service-to-service requests, cache lookups) become children or descendants of this root.
Common Entry Points
Your root spans are usually created at API gateways, load balancers, or edge services—the first components that handle incoming traffic from clients or external systems. These are strategic locations because:
- They intercept 100% of requests entering your system
- They're the natural place to generate a new
trace_idif one doesn't exist - They initialize trace context that propagates downstream
For example, when a mobile app calls https://api.example.com/orders, your API gateway creates the root span, assigns it a unique trace ID, and begins tracking timing. As that request flows through your order service → inventory service → payment service, each creates child spans that reference back to that root.
Initializing Context
At the entry point, you either:
- Create new context if this is a fresh request (generate
trace_idandspan_id) - Continue existing context if the caller already sent trace headers (distributed tracing across organizational boundaries)
Think of the root span as planting a flag at the start of a journey—every step that follows can trace its path back to that original marker.
Key Takeaway: Root spans are created at system entry points (API gateways, load balancers) where trace context is initialized or continued, establishing the foundation for tracking requests across your distributed architecture.